저는 Cython 문서를보고 각 예제 응용 프로그램을 작성 중입니다. 나는 C 라이브러리 사용에 조금 머물러있다. .so 파일을 성공적으로 빌드하고 test.py라는 python 파일로 가져 오려고하면 다음 오류가 발생합니다.Cython에서 생성 한 .so 파일을 가져올 때이 ImportError의 의미는 무엇입니까?
$ python3.2 test.py
Traceback (most recent call last):
File "test.py", line 12, in <module>
from queue import Queue
ImportError: dlopen(/Users/jeremy/Development/labs/python/cython_lib_wrapper/queue.so, 2): Symbol not found: _queue_free
Referenced from: /Users/jeremy/Development/labs/python/cython_lib_wrapper/queue.so
Expected in: flat namespace
in /Users/jeremy/Development/labs/python/cython_lib_wrapper/queue.so
.so 파일은 test.py 파일 옆에 있습니다. 그래서 그것은 발견되어야하는 것처럼 보입니다. 이것은 Cython의 최신 버전을 실행하며, OSX 10.6에서 Python 3.2를 사용합니다.
통찰력이 있으십니까?
편집 - 명령과 출력을 구축 추가
$ python3.2 setup.py build_ext --inplace
running build_ext
cythoning queue.pyx to queue.c
building 'queue' extension
gcc-4.2 -fno-strict-aliasing -fno-common -dynamic -DNDEBUG -g -O3 -isysroot /Developer/SDKs/MacOSX10.6.sdk -arch i386 -arch x86_64 -isysroot /Developer/SDKs/MacOSX10.6.sdk -I/Library/Frameworks/Python.framework/Versions/3.2/include/python3.2m -c queue.c -o build/temp.macosx-10.6-intel-3.2/queue.o
queue.c: In function ‘__pyx_f_5queue_5Queue_append’:
queue.c:627: warning: cast to pointer from integer of different size
queue.c: In function ‘__pyx_f_5queue_5Queue_extend’:
queue.c:740: warning: cast to pointer from integer of different size
queue.c: In function ‘__pyx_f_5queue_5Queue_peek’:
queue.c:813: warning: cast from pointer to integer of different size
queue.c: In function ‘__pyx_f_5queue_5Queue_pop’:
queue.c:965: warning: cast from pointer to integer of different size
gcc-4.2 -bundle -undefined dynamic_lookup -arch i386 -arch x86_64 -isysroot /Developer/SDKs/MacOSX10.6.sdk -isysroot /Developer/SDKs/MacOSX10.6.sdk -g build/temp.macosx-10.6-intel-3.2/queue.o -o
편집 2 - cmd를 코멘트에 요청 "otool"추가
queue.so:
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 125.2.0)
편집 3 - 추가 "나노"출력
U ___stack_chk_fail
U ___stack_chk_guard
U _queue_free
U _queue_is_empty
U _queue_new
U _queue_peek_head
U _queue_pop_head
U _queue_push_tail
U dyld_stub_binder
개
그렙 cmd를 출력이 :
(undefined) external _queue_free (dynamically looked up)
이것은 연결 문제처럼 보입니다. 다시 빌드하고 빌드 출력과 여기서 빌드하는 데 사용 된 명령을 모두 포함 할 수 있습니까? – stderr
@Mike Steder 이걸 살펴 줘서 고마워, 내가 빌드 명령과 출력을 추가했습니다. – JeremyFromEarth
좋아요, 재수 없기 때문에 재연을 해보 죠. 'nm queue.so'를 시도하고 _queue_free 옆에 나열된 것을보십시오. 또한'otool -L queue.so'를 사용하고 DYLD_LIBRARY_PATH ('echo $ DYLD_LIBRARY_PATH')를 확인하십시오. – stderr