我在 Linux 中使用 C++ (Eclipse) 工作,并且想要使用一个库。 Eclipse 显示一个错误:
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);
}
最佳答案
您必须链接到 libdl,添加
-ldl
到你的链接器选项
关于c++ - Linux C++错误: undefined reference to 'dlopen' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55079602/