rrlangly <richard.ringo.lan...@gmail.com> writes: > Hi, > > This is a small test case I wrote in which I can't understand why I have an > undefined reference. I have an undefined reference which I thought only > requires linking w/ the libs that contain this symbol, which I am. The > function dm_connect() is in the library libdm, and this is on the g++ > command line when I compile as shown. The libdm is a C library and I'm > calling this in my C++ program. > > Can anyone help me understand what I'm doing wrong? > > --- Compile and Error > > $ g++ $(pkg-config --cflags glib-2.0) -I/usr/include -I/usr/local/include > -I/home/joe/Projects/net-1.0/util -L/usr/local/lib > -L/home/joe/Projects/net-1.0/libdm $(pkg-config --libs glib-2.0) -ldm > main.cpp > /tmp/ccksTRGA.o: In function `main': > main.cpp:(.text+0x30): undefined reference to `dm_connect(char*, unsigned > short)' > collect2: ld returned 1 exit status > > --- Source > #include <stdio.h> > > #include "gxclient.h" > > using namespace std; > > int main () > { > int fd = -1; > > uint16_t port = 11002; > > char *dmhostname = "localhost"; > > fd = dm_connect(dmhostname, port); > > if (fd < 0) { > printf("failed\n"); > } > > return 0; > }
Check what dm library is loaded: gcc -Wl,-t ... or ld -t ... Check the symbols in that library: nm /usr/lib/libdm.so.1.0.0 or nm /usr/lib/libdm.so.1.0.0 | grep dm_connect -- __Pascal Bourguignon__ _______________________________________________ help-gplusplus mailing list help-gplusplus@gnu.org http://lists.gnu.org/mailman/listinfo/help-gplusplus