undefined reference to `dlopen'

时间:2022-06-15 06:23:43

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之前导致的

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