This is the mail archive of the
libc-help@sourceware.org
mailing list for the glibc project.
trying to understand undefined reference for dladdr
- From: Brendan Miller <catphive at catphive dot net>
- To: libc-help at sourceware dot org
- Date: Tue, 18 Aug 2009 15:56:12 -0700
- Subject: trying to understand undefined reference for dladdr
I have some code like:
#include <dlfcn.h>
...
// function call in some code later.
dladdr(addr, &addrInfo);
That is compiled into a static library libmy_library.a
When I go to link the library into the program containing my main
routine I get this:
g++ -o program -rdynamic main.o libmy_library.a
libmy_library.a(my_library.o): In function `SomeFunction(void*)':
/path/to/src/my_library.cpp:68: undefined reference to `dladdr'
collect2: ld returned 1 exit status
How can I get an undefined reference to something in glibc? I was
using other glibc functions fine, but dladdr seemed to throw it for a
loop. Maybe this has something to do with it being part of the family
of functions for dynamic loading libraries, and I'm trying to link it
from a static lib? I'm using lots of other glibc functions without
trouble. Are the dl* functions linked in some weird way?
Thanks,
Brendan