main.cpp:(.text+0x19): undefined reference to `dlopen'
main.cpp:(.text+0x22): undefined reference to `dlerror'
main.cpp:(.text+0x62): undefined reference to `dlsym'
需要在编译时加上-ldl。
将原来的编译命令:g++ cfgfile.cpp create.cpp main.cpp -o main
main.cpp:(.text+0x22): undefined reference to `dlerror'
main.cpp:(.text+0x62): undefined reference to `dlsym'
需要在编译时加上-ldl。
将原来的编译命令:g++ cfgfile.cpp create.cpp main.cpp -o main
修改为:g++ cfgfile.cpp create.cpp main.cpp -o main -ldl
另外,如果是进行多线程开发时,在编译时需加上-lpthread

本文介绍了解决C++程序中出现的未定义符号引用错误的方法,特别是针对使用了动态链接库的情况。通过添加正确的编译选项-ldl可以解决dlopen、dlerror和dlsym等函数未找到的问题。
841

被折叠的 条评论
为什么被折叠?



