我在C++(Eclipse)的Linux工作,并希望使用库。 Eclipse给我显示了一个错误:Linux的c + +错误:未定义引用'dlopen'
undefined reference to 'dlopen'
你知道一个解决方案吗?
这里是我的代码:
#include <stdlib.h>
#include <stdio.h>
#include <dlfcn.h>
int main(int argc, char **argv) {
void *handle;
double (*desk)(char*);
char *error;
handle = dlopen ("/lib/CEDD_LIB.so.6", RTLD_LAZY);
if (!handle) {
fputs (dlerror(), stderr);
exit(1);
}
desk= dlsym(handle, "Apply");
if ((error = dlerror()) != NULL) {
fputs(error, stderr);
exit(1);
}
dlclose(handle);
}
我遇到了同样的问题,在文档 从$男人GCC一个相当简洁的解释... 我在Project> Properties> C/C++ Build> Settings>(My Linker)下添加了编译器标志, >链接器标志文本字段中的其他内容。它什么都没做。 – MirroredFate 2013-02-02 07:09:49
哈,好吧,对于任何有此问题的人,请使用上面的路径,除了去图书馆而不是杂项,并添加'dl' – MirroredFate 2013-02-02 07:53:42
这个答案有帮助。对于任何想要查找libdl.so位置的人,只需进入根目录并键入'locate libdl.so' – Nav 2013-07-04 11:46:22