找不到连接libruli.so的g ++符号

时间:2012-11-22 09:55:45

标签: linker g++ shared-objects

对于我可以检查哪些符号未找到符号的任何想法都很有用。是的,所以lib被发现路径在/etc/ld.so.conf中设置 (http://www.nongnu.org/ruli/)

g ++ --version g ++(GCC)3.3.3(SuSE Linux)

g ++ -D_xx_ -I ../ se / yy / xx / business / ss / utility / asn -I / usr / local / include / mysql ++ -I / usr / include / mysql -O0 -g3 -Wall -c -fmessage-length = 0 -MMD -MP - MF“se / yy / xx / business / ss / communication / ClientSocketThread.d”-MT“se / yy / xx / business / ss / communication / ClientSocketThread.d”-o “se / yy / nn是/ business / ss / communication / ClientSocketThread.o”“../ se / yy / xx / business / ss / communication / ClientSocketThread.cpp”

////

./se/yy/xx/business/ss/communication/ServerSocketThread.o ./se/yy/xx/business/ss/communication/SocketThread.o ./se/yy/xx/business/ss/communication/ThreadBase.o   -lpthread -lxml2 -lruli -loop -lasn1per -lasn1rt -lmysqlpp
./se/yy/xx/business/ss/communication/ClientSocketThread.o(.text+0xc17): In function `ClientSocketThread::Connect(char const*, char const*, int)':
../se/yy/xx/business/ss/communication/ClientSocketThread.cpp:152: undefined reference to `ruli_sync_query(char const*, char const*, int, long)'
./se/yy/xx/business/ss/communication/ClientSocketThread.o(.text+0xdb1):../se/yy/xx/business/ss/communication/ClientSocketThread.cpp:161: undefined reference to `ruli_sync_srv_code(ruli_sync_t const*)'
./se/yy/xx/business/ss/communication/ClientSocketThread.o(.text+0xf55):../se/yy/xx/business/ss/communication/ClientSocketThread.cpp:173: undefined reference to `ruli_sync_rcode(ruli_sync_t*)'
./se/yy/xx/business/ss/communication/ClientSocketThread.o(.text+0x1123):../se/yy/xx/business/ss/communication/ClientSocketThread.cpp:185: undefined reference to `ruli_sync_srv_list(ruli_sync_t*)'
./se/yy/xx/business/ss/communication/ClientSocketThread.o(.text+0x113a):../se/yy/xx/business/ss/communication/ClientSocketThread.cpp:186: undefined reference to `ruli_list_size(ruli_list_t const*)'
./se/yy/xx/business/ss/communication/ClientSocketThread.o(.text+0x14ad):../se/yy/xx/business/ss/communication/ClientSocketThread.cpp:204: undefined reference to `ruli_list_get(ruli_list_t const*, int)'
./se/yy/xx/business/ss/communication/ClientSocketThread.o(.text+0x14d5):../se/yy/xx/business/ss/communication/ClientSocketThread.cpp:206: undefined reference to `ruli_list_size(ruli_list_t const*)'
./se/yy/xx/business/ss/communication/ClientSocketThread.o(.text+0x150b):../se/yy/xx/business/ss/communication/ClientSocketThread.cpp:213: undefined reference to `ruli_dname_decode(char*, int, int*, char const*, int)'
./se/yy/xx/business/ss/communication/ClientSocketThread.o(.text+0x1753):../se/yy/xx/business/ss/communication/ClientSocketThread.cpp:225: undefined reference to `ruli_list_get(ruli_list_t const*, int)'
./se/yy/xx/business/ss/communication/ClientSocketThread.o(.text+0x176a):../se/yy/xx/business/ss/communication/ClientSocketThread.cpp:226: undefined reference to `ruli_addr_family(ruli_addr_t const*)'
./se/yy/xx/business/ss/communication/ClientSocketThread.o(.text+0x17a7):../se/yy/xx/business/ss/communication/ClientSocketThread.cpp:229: undefined reference to `ruli_in_snprint(char*, unsigned, _ruli_addr const*, int)'
collect2: ld returned 1 exit status
make: *** [SlisServer] Error 1


sudo ldd /usr/local/lib/libruli.so
        linux-gate.so.1 =>  (0xffffe000)
        liboop.so.4 => /usr/local/lib/liboop.so.4 (0x40025000)
        libdl.so.2 => /lib/libdl.so.2 (0x4002c000)
        libc.so.6 => /lib/tls/libc.so.6 (0x40030000)
        /lib/ld-linux.so.2 (0x80000000)

就我所见,所有符号在lib中看起来都不错

 sudo readelf -Ws /usr/local/lib/libruli.so | grep ruli_sync
    65: 0000ee90   373 FUNC    GLOBAL DEFAULT   11 ruli_sync_smtp_query@@libruli4
   105: 0000eb90   103 FUNC    GLOBAL DEFAULT   11 ruli_sync_rcode@@libruli4
   126: 0000ed10   376 FUNC    GLOBAL DEFAULT   11 ruli_sync_http_query@@libruli4
   127: 0000eb20   103 FUNC    GLOBAL DEFAULT   11 ruli_sync_srv_list@@libruli4
   162: 0000ec00   103 FUNC    GLOBAL DEFAULT   11 ruli_sync_srv_code@@libruli4
   197: 0000f010   373 FUNC    GLOBAL DEFAULT   11 ruli_sync_query@@libruli4
   236: 0000ec70   158 FUNC    GLOBAL DEFAULT   11 ruli_sync_delete@@libruli4

 sudo readelf -Ws /usr/local/lib/libruli.so | grep ruli_list
    35: 00004c20    66 FUNC    GLOBAL DEFAULT   11 ruli_list_capacity@@libruli4
    63: 00004cf0   170 FUNC    GLOBAL DEFAULT   11 ruli_list_clean@@libruli4
    64: 00004ea0   217 FUNC    GLOBAL DEFAULT   11 ruli_list_dispose@@libruli4
    74: 000050b0    67 FUNC    GLOBAL DEFAULT   11 ruli_list_new@@libruli4
    75: 00004c70   127 FUNC    GLOBAL DEFAULT   11 ruli_list_size@@libruli4
    92: 0001201c     4 OBJECT  GLOBAL DEFAULT   14 ruli_list_malloc@@libruli4
    99: 00004b90   140 FUNC    GLOBAL DEFAULT   11 ruli_list_push@@libruli4
   100: 000048b0   271 FUNC    GLOBAL DEFAULT   11 ruli_list_shift_at@@libruli4
   104: 00012014     4 OBJECT  GLOBAL DEFAULT   14 ruli_list_free@@libruli4
   108: 00004da0   140 FUNC    GLOBAL DEFAULT   11 ruli_list_clean_trivial@@libruli4
   118: 00004820   131 FUNC    GLOBAL DEFAULT   11 ruli_list_top@@libruli4
   133: 00012018     4 OBJECT  GLOBAL DEFAULT   14 ruli_list_realloc@@libruli4
   134: 00004f80   150 FUNC    GLOBAL DEFAULT   11 ruli_list_dispose_trivial@@libruli4
   140: 00004790   133 FUNC    GLOBAL DEFAULT   11 ruli_list_pop@@libruli4
   156: 000044b0    23 FUNC    GLOBAL DEFAULT   11 ruli_list_errstr@@libruli4
   161: 000046e0   176 FUNC    GLOBAL DEFAULT   11 ruli_list_drop@@libruli4
   169: 00004e30   112 FUNC    GLOBAL DEFAULT   11 ruli_list_delete@@libruli4
   209: 00005020   142 FUNC    GLOBAL DEFAULT   11 ruli_list_new_cap@@libruli4
   220: 00004580   165 FUNC    GLOBAL DEFAULT   11 ruli_list_set@@libruli4
   222: 00004a70   274 FUNC    GLOBAL DEFAULT   11 ruli_list_insert_at@@libruli4
   232: 00004630   162 FUNC    GLOBAL DEFAULT   11 ruli_list_get@@libruli4
   235: 000044d0   161 FUNC    GLOBAL DEFAULT   11 ruli_list_prune@@libruli4


 sudo readelf -Ws /usr/local/lib/libruli.so | grep ruli_dname_decode
   229: 00006de0   256 FUNC    GLOBAL DEFAULT   11 ruli_dname_decode@@libruli4

 sudo readelf -Ws /usr/local/lib/libruli.so | grep ruli_in_snp
   165: 00005f00   125 FUNC    GLOBAL DEFAULT   11 ruli_in_snprint@@libruli4

Har testatattläggauntil en av funktionsanropen(cut / paste samma kod)i en av test funktionerna i ruli lib ochdetlänkarutanproblem mot samma lib。

gcc   -O2 -pipe -Wall -g -I../src -I/usr/local/oop/include -c srvsearch.c
gcc   -O2 -pipe -Wall -g -I../src -I/usr/local/oop/include -c parse_options.c
gcc   -O2 -pipe -Wall -g -I../src -I/usr/local/oop/include -c stdout_srv_list.c
gcc  -L../src -L/usr/local/oop/lib  -o srvsearch srvsearch.o parse_options.o stdout_srv_list.o  -lruli -loop
gcc   -O2 -pipe -Wall -g -I../src -I/usr/local/oop/include -c sync_srvsearch.c
gcc  -L../src -L/usr/local/oop/lib  -o sync_srvsearch sync_srvsearch.o parse_options.o stdout_srv_list.o  -lruli -loop
gcc   -O2 -pipe -Wall -g -I../src -I/usr/local/oop/include -c smtpsearch.c
gcc  -L../src -L/usr/local/oop/lib  -o smtpsearch smtpsearch.o parse_options.o stdout_srv_list.o  -lruli -loop
gcc   -O2 -pipe -Wall -g -I../src -I/usr/local/oop/include -c sync_smtpsearch.c
gcc  -L../src -L/usr/local/oop/lib  -o sync_smtpsearch sync_smtpsearch.o parse_options.o stdout_srv_list.o  -lruli -loop
gcc   -O2 -pipe -Wall -g -I../src -I/usr/local/oop/include -c sync_httpsearch.c
gcc  -L../src -L/usr/local/oop/lib  -o sync_httpsearch sync_httpsearch.o parse_options.o stdout_srv_list.o  -lruli -loop
gcc   -O2 -pipe -Wall -g -I../src -I/usr/local/oop/include -c httpsearch.c
gcc  -L../src -L/usr/local/oop/lib  -o httpsearch httpsearch.o parse_options.o stdout_srv_list.o  -lruli -loop
gcc   -O2 -pipe -Wall -g -I../src -I/usr/local/oop/include -c ruli-getaddrinfo.c
ruli-getaddrinfo.c: In function `main':
ruli-getaddrinfo.c:60: warning: `sync_query' might be used uninitialized in this function
gcc   -O2 -pipe -Wall -g -I../src -I/usr/local/oop/include -c addrprint.c
gcc  -L../src -L/usr/local/oop/lib  -o ruli-getaddrinfo ruli-getaddrinfo.o addrprint.o parse_options.o  -lruli -loop
gcc   -O2 -pipe -Wall -g -I../src -I/usr/local/oop/include -c getaddrinfo.c
gcc   -O2 -pipe -Wall -g -I../src -I/usr/local/oop/include -c run_getaddrinfo.c
gcc  -L../src -L/usr/local/oop/lib  -o getaddrinfo getaddrinfo.o run_getaddrinfo.o addrprint.o parse_options.o  -ldl

对任何提示都很重要

1 个答案:

答案 0 :(得分:1)

libruli.so中定义的符号具有extern "C"链接。

您未解析的符号具有C++链接(请注意链接器如何列出函数参数类型)。

正如chill正确猜测的那样,这意味着libruli附带的标头没有正确的C++警卫。要解决此问题,请不要这样做(在C ++代码中):

#include "libruli.h"

请改为:

extern "C" {
#include "libruli.h"
}

或者,修复libruli.h本身(并向其开发人员发送补丁):

#ifdef __cplusplus
extern "C" {
#endif

... original content goes here ...

#ifdef __cplusplus
}
#endif