我試圖將我的mac應用程序鏈接到美妙的libancillary庫。但是,我更改了庫構建腳本以創建共享庫。我可以用nm libancillary.dylib
檢查這個庫中的符號 - 其結果是:ld報告丟失的符號,但符號似乎存在
libancillary.dylib(single module):
U ___sF
U __keymgr_get_and_lock_processwide_ptr
U __keymgr_get_and_lock_processwide_ptr_2
U __keymgr_set_and_unlock_processwide_ptr
U _abort
00002cfe T _ancil_recv_fd
00002c87 T _ancil_recv_fds
00002b6a T _ancil_recv_fds_with_buffer
00002e9e T _ancil_send_fd
00002e27 T _ancil_send_fds
00002d3f T _ancil_send_fds_with_buffer
U _calloc
U _dlopen
U _dlsym
U _fflush
U _fprintf
U _free
U _malloc
U _recvmsg
U _sendmsg
然而,當我嘗試鏈接到我的應用程序時,輸出我得到的是:
g++ -headerpad_max_install_names -framework AppKit -framework Cocoa -framework IOKit -framework CoreFoundation -framework Carbon -framework OpenGL -framework SystemConfiguration -framework Security -Wl,-bind_at_load -arch i386 -o MyApp build/app.o build/client.o build/util.o -F/Library/Frameworks -L/Library/Frameworks -L../ancillary -lancillary
Undefined symbols:
"ancil_recv_fd(int, int*)", referenced from:
CIPCUnixUtils::readFD(int, int&) constin utils.o
"ancil_send_fd(int, int)", referenced from:
CIPCUnixUtils::writeFD(int, int) constin utils.o
ld: symbol(s) not found
collect2: ld returned 1 exit status
make: *** [ABClient] Error 1
(我已編輯這個稍微刪除很長的目標文件列表)。
什麼可能導致此連接失敗?該符號存在並且是公共的,並且不能找到該庫或任何其他錯誤消息。
類似的問題在這裏: http://stackoverflow.com/questions/942754/nm-reports-symbol-is-defined-but-ldd-reports-symbol-is-undefined 除了我的符號顯示作爲公衆。 – Thomi 2010-03-30 08:38:10
與linux相比,您不必使用nm -D來查看動態鏈接的符號,還是它在osx上的工作方式不同? – 2012-03-21 16:42:47