|
|
Why do I need __USE_GNU to use RTLD_NEXT (Debian Linux) ?
C programming question.
I have #include <dlfcn.h>, to declare dlsym() and define RTLD_NEXT.
I found that it doesn't work (complains that RTLD_NEXT is undefined)
unless I do this:
#define __USE_GNU
#include <dlfcn.h>
Is this advised? Why is it necessary?
|
|
0
|
|
|
|
Reply
|
gazelle
|
5/7/2004 4:30:21 AM |
|
On Fri, 07 May 2004 04:30:21 GMT, gazelle@yin.interaccess.com (Kenny
McCormack) wrote:
>C programming question.
>
>I have #include <dlfcn.h>, to declare dlsym() and define RTLD_NEXT.
>I found that it doesn't work (complains that RTLD_NEXT is undefined)
>unless I do this:
>
>#define __USE_GNU
>#include <dlfcn.h>
>
>Is this advised? Why is it necessary?
You should be defining _GNU_SOURCE, which in turn sets __USE_GNU. Do
not set the latter macro directly.
The _GNU_SOURCE macro enables a number of GNU extensions to various
standards. Prior to glibc version 2, these extensions were
automatically made available by various library header files. But,
this can lead to various problems when trying to port code to other
Unix implementations. So, glibc 2 and later do not include these
extensions unless the program defines _GNU_SOURCE.
Cheers,
Michael
|
|
0
|
|
|
|
Reply
|
Michael
|
5/7/2004 6:40:52 AM
|
|
Kenny McCormack <gazelle@yin.interaccess.com> wrote:
> C programming question.
> I have #include <dlfcn.h>, to declare dlsym() and define RTLD_NEXT.
> I found that it doesn't work (complains that RTLD_NEXT is undefined)
> unless I do this:
> #define __USE_GNU
> #include <dlfcn.h>
> Is this advised? Why is it necessary?
The POSIX standard (aka SUSv3) is only talking about RTLD_LAZY,
RTLD_NOW, RTLD_GLOBAL and RTLD_LOCAL, while RTLD_NEXT and
RTLD_DEFAULT are GNU extensions. In order not to interfer with
fully POSIX compliant programs that may use these extra names
for their own private purposes they aren't defined by default
but only when you explicitely ask for them by #define'ing some
special constant. BTW, the Linux man page I have here says that
you have to #define _GNU_SOURCE to get these values instead of
__USE_GNU. A quick look at <features.h> seems to indicate that
_GNU_SOURCE turns on __USE_GNU, but also a lot of other stuff.
It might be dangerous to turn on just __USE_GNU without having
also the other features you enable via _GNU_SOURCE...
Regards, Jens
--
\ Jens Thoms Toerring ___ Jens.Toerring@physik.fu-berlin.de
\__________________________ http://www.toerring.de
|
|
0
|
|
|
|
Reply
|
Jens
|
5/7/2004 8:41:19 AM
|
|
|
2 Replies
582 Views
(page loaded in 2.112 seconds)
|
|
|
|
|
|
|
|
|