'RTLD_NEXT' undeclared

2020-06-07 03:07发布

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?

4条回答
手持菜刀,她持情操
2楼-- · 2020-06-07 03:28

According to man dlsym it is #define _GNU_SOURCE (just one leading underscore) before the dlfcn.h is included. (RHEL6.1).

查看更多
祖国的老花朵
3楼-- · 2020-06-07 03:28

There must be one underscore. #define _GNU_SOURCE Further, this must be your first preprocessor directive.For example:

#define _GNU_SOURCE  
#include <stdio.h>
查看更多
够拽才男人
4楼-- · 2020-06-07 03:29

Try #define __GNU_SOURCE as first line in your sources.

查看更多
Juvenile、少年°
5楼-- · 2020-06-07 03:34

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.

查看更多
登录 后发表回答