gpt4 book ai didi

linux - 对 `dlopen' 的 undefined reference

转载 作者:塔克拉玛干 更新时间:2023-11-02 23:14:59 26 4
gpt4 key购买 nike

我有一个程序不是用现代 GCC 构建的,输出很傻:

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 上搜索了 advise,但只找到了将 -ldl 添加到链接器的建议。但这在这里没有帮助。我该怎么办?

最佳答案

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

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 

关于linux - 对 `dlopen' 的 undefined reference ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6183899/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com