2010-03-30 4 views
6

내 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 

은 (난이 편집 한 객체 파일의 매우 긴 목록을 제거하려면 약간.

이 연결이 실패 할 수있는 원인은 무엇입니까? 심볼이 존재하며 공개되어 있으며 라이브러리를 찾을 수 없다는 오류 또는 기타 오류 메시지가 없습니다.

+0

비슷한 질문 : http://stackoverflow.com/questions/942754/nm-reports-symbol-is-defined-but-ldd-reports-symbol-is-undefined 내 기호가 표시되는 것을 제외 공개로. – Thomi

+0

nm -D를 사용하여 동적으로 링크 된 심볼을 볼 필요가 없나요? 아니면 osx에서 linux와 다르게 작동합니까? –

답변

7

이 기호는 기호가없는 기호입니다. 이 태그를 C++로 태그 지정 했으므로 C++로 컴파일한다고 가정합니다. 당신은 당신이 당신의 라이브러리 코드에 통근 블록의 헤더 파일 포장해야 할 수도 할 경우

library.h 라이브러리의 헤더 파일 (들), 그가에 엉망이되는 것을 방지하기 위해의 이름입니다
extern "C" { 
#include "library.h" 
} 

호출 코드.

+0

Doh - 나는 그것을 생각해야만했다. 감사. – Thomi

1

C++ 이름 - mangling 문제가 궁금해?

파일에서 nm을 실행하고 실제로 어떤 기호가 표시되는지 확인하십시오.

extern C에 머리글을 포장해야 할 수도 있습니다. 여기

관련 문제