对“dlopen"的未定义引用 [英] undefined reference to `dlopen'

查看:58
本文介绍了对“dlopen"的未定义引用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个不使用现代 GCC 构建的程序,输出很愚蠢:

I have a program that does not build with modern GCC with the foollowing output:

gcc -I/usr/lib/qt3/include -I/opt/kde3/include/  -fmessage-length=0 -O2 -Wall -D_FORTIFY_SOURCE=2 -fstack-protector -funwind-tables -fasynchronous-unwind-tables -lqt-mt -ldl -L/usr/lib/qt3/lib64 -o autocheck autocheck.cpp
autocheck.cpp: In function 'int main(int, char**)':
autocheck.cpp:64:62: warning: too many arguments for format
autocheck.cpp:79:79: warning: too many arguments for format
/tmp/ccOFReGf.o: In function `main':
autocheck.cpp:(.text+0x244): undefined reference to `dlopen'
autocheck.cpp:(.text+0x2e1): undefined reference to `dlerror'
collect2: ld returned 1 exit status

我在 Internet 上搜索了建议,但只找到了将 -ldl 添加到链接器的建议.但这在这里没有帮助.我该怎么办?

I searched the Internet for advise but only found a recommendation to add -ldl to the linker. But this does not help here. What should I do?

推荐答案

移动 autocheck.cpp 使其位于命令中的库之前.仅在库中搜索需要在出现在它们之前的文件中解析的内容.所以你的命令应该是这样的:

Move autocheck.cpp so that it is before the libraries in your command. Libraries are only searched for things that need resolving in files that appear before them. So your command should look like this:

gcc autocheck.cpp -I/usr/lib/qt3/include -I/opt/kde3/include/  -fmessage-length=0 -O2 -Wall -D_FORTIFY_SOURCE=2 -fstack-protector -funwind-tables -fasynchronous-unwind-tables -lqt-mt -ldl -L/usr/lib/qt3/lib64 -o autocheck 

这篇关于对“dlopen"的未定义引用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆