undefined reference to `dlopen'

本文介绍了使用g++编译过程中出现的链接错误及其解决方法。主要原因是-l(dl)选项的位置不当,导致某些符号未被正确链接。通过调整链接库的顺序可以有效解决问题。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

g++ -O0 -g3 -I. -Ithird/json -Ithird/core/include -Ithird/vite/include -Ithird/openfst-1.2.10/src/include -o a.out test/test.c test/build/testbuild.o test/train/test_lm2.o test/tool/load_two/load_two.o test/tool/multi_thread/test-multi.o test/tool/mem_check/mem_check.o test/tool/test_ncc/test_nc.o lib/lm.a -lpthread -ldl -lrt -lm -L/usr/local/lib third/vite/lib/vite_g.a third/core/lib/core_g.a -liconv
third/core/lib/core_g.a(sqlite3.o): In function `unixDlOpen':
/home/jfyuan/svn/aispeech/speechplatform/branches/wtk-jfy/third/sqlite/sqlite3.c:29024: undefined reference to `dlopen'
third/core/lib/core_g.a(sqlite3.o): In function `unixDlError':
/home/jfyuan/svn/aispeech/speechplatform/branches/wtk-jfy/third/sqlite/sqlite3.c:29038: undefined reference to `dlerror'
third/core/lib/core_g.a(sqlite3.o): In function `unixDlSym':
/home/jfyuan/svn/aispeech/speechplatform/branches/wtk-jfy/third/sqlite/sqlite3.c:29064: undefined reference to `dlsym'
third/core/lib/core_g.a(sqlite3.o): In function `unixDlClose':
/home/jfyuan/svn/aispeech/speechplatform/branches/wtk-jfy/third/sqlite/sqlite3.c:29069: undefined reference to `dlclose'
collect2: error: ld returned 1 exit status

原因:-ldl 在core_g.a之前导致的

解决办法:调换一下顺序即可。

转载于:https://www.cnblogs.com/tibetanmastiff/p/5761716.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值