升级至 11.10 后出现链接问题

升级至 11.10 后出现链接问题

这里有一个我无法解释的问题。链接器抱怨 Oracle 客户端库中的符号未定义:

$ gcc-4.6 -L/usr/local/oracle/product/11.2.0/dbhome_1/lib -lcurl -m64 -lpthread -lclntsh  advarc.o wintbx.a winlib_o.a   -o advarc
advarc.o: In function `main':
advarc.c:(.text+0x1c68): undefined reference to `sqlcxt'
advarc.c:(.text+0x1f19): undefined reference to `sqlcxt'
advarc.c:(.text+0x1fb3): undefined reference to `sqlcxt'
advarc.c:(.text+0x21cc): undefined reference to `sqlcxt'
advarc.c:(.text+0x25f9): undefined reference to `sqlcxt'
advarc.o:advarc.c:(.text+0x2693): more undefined references to `sqlcxt' follow
wintbx.a(stlthread.o): In function `initialiseThread':
stlthread.c:(.text+0x70): undefined reference to `pthread_setconcurrency'
stlthread.c:(.text+0x8a): undefined reference to `pthread_create'
winlib_o.a(winlib_o.o): In function `dbconnect':
winlib_o.c:(.text+0x8f6): undefined reference to `sqlcxt'
winlib_o.c:(.text+0xa39): undefined reference to `sqlcxt'
winlib_o.a(winlib_o.o): In function `dbdisconnect':
winlib_o.c:(.text+0xb03): undefined reference to `sqlcxt'
winlib_o.a(winlib_o.o): In function `dbdynamic':
winlib_o.c:(.text+0xd44): undefined reference to `sqlcxt'
winlib_o.c:(.text+0xef3): undefined reference to `sqlcxt'
winlib_o.a(winlib_o.o):winlib_o.c:(.text+0xf89): more undefined references to `sqlcxt' follow
collect2: ld returned 1 exit status

但根据nm,该符号的定义是:

nm /usr/local/oracle/product/11.2.0/dbhome_1/lib/libclntsh.so | grep sqlcxt
0000000001d154f0 T sqlcxt

我能够构建并运行相同的代码,直至(包括)Ubuntu 11.04。libclntsh 库已重新链接到新的系统库。

答案1

我不知道 gcc-4.6 是否仍然如此,但在早期版本中,您需要附加要链接的库。尝试:

gcc-4.6 -L/usr/local/oracle/product/11.2.0/dbhome_1/lib advarc.o wintbx.a winlib_o.a -lcurl -m64 -lpthread -lclntsh  -o advarc

(我改变了论点的顺序)

相关内容