views:

615

answers:

2

I'm trying to compile a C program but I get the error 'RTLD_NEXT' undeclared. I think this is supposed to be defined in dlfcn.h which the c program includes, but when I looked inside dlfcn.h there is no RTLD_NEXT.

How do I fix this?

+2  A: 

Try #define _GNU_SOUCE as first line in your sources.

+1; changed code formatting from quotes to backticks
Christoph
It's already there in the program source.
Phenom
Should be `__GNU_SOURCE`
Michael Mior
+2  A: 

The issue here is that RTLD_NEXT is not defined by the posix standard . So the GNU people don't enable it unless you #define _GNU_SOURCE or -D_GNU_SOURCE.

Other relevant pieces of POSIX are dlfcn.h and dlsym.h. Interestingly, the later mentions RTLD_NEXT. Apparently, the GNU people are a bit confused about what is an extension and what is not.

bmargulies
better link to http://www.opengroup.org/onlinepubs/009695399/basedefs/dlfcn.h.html and http://www.opengroup.org/onlinepubs/009695399/functions/dlsym.html#tag_03_112_07
Christoph