我使用bar_extension
创建了一个python扩展distutils
。bar_extension
需要一个由libfoo.dylib
生成的共享对象cmake
。
这是我的setup.py
:
from distutils.core import setup, Extension
module1 = Extension('bar_extension',
libraries=['libfoo2.dylib', ],
library_dirs=['/Users/xiazhibin/CLionProjects/study/lib', ],
include_dirs=['/Users/xiazhibin/CLionProjects/study/include', ],
language="c++",
extra_compile_args = ['-v', '--std=c++98', ],
sources=['main.cpp'])
setup(name='PackageName',
version='1.0',
description='This is a demo package',
ext_modules=[module1])
输出在这里:
"/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/lipo" -create -output build/temp.macosx-10.11-intel-2.7/main.o /var/folders/45/gz7ljrz94mdct3nvm9l5ftnr0000gp/T/main-5498b8.o /var/folders/45/gz7ljrz94mdct3nvm9l5ftnr0000gp/T/main-0bc98d.o
c++ -bundle -undefined dynamic_lookup -arch i386 -arch x86_64 -Wl,-F. build/temp.macosx-10.11-intel-2.7/main.o -L/Users/xiazhibin/CLionProjects/study/lib -llibfoo2.dylib -o build/lib.macosx-10.11-intel-2.7/bar.so
ld: library not found for -llibfoo2.dylib
clang: error: linker command failed with exit code 1 (use -v to see invocation)
error: command 'c++' failed with exit status 1
我的libfoo2.dylib
位于路径/Users/xiazhibin/CLionProjects/study/lib
下,但似乎无法找到我的libfoo2.dylib
谢谢!