Linux 制作插件出现undefined reference to `dlerror‘问题

usr/bin/ld: /tmp/ccVDsrnE.o: in function `main':
main.cpp:(.text+0x19): undefined reference to `dlerror'
/usr/bin/ld: main.cpp:(.text+0x5d): undefined reference to `dlsym'
/usr/bin/ld: main.cpp:(.text+0xb0): undefined reference to `dlclose'
/usr/bin/ld: /tmp/ccVDsrnE.o: in function `__static_initialization_and_destruction_0(int, int)':
main.cpp:(.text+0x112): undefined reference to `dlopen'
collect2: error: ld returned 1 exit status
 

出现该问题,需要在#include <dlfcn.h>,如果仍然无法解决,在用命令行编译时,添加一个参数:  -ldl


版权声明:本文为benladeng29hao原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。