osx上的python扩展链接dylib

时间:2017-07-26 09:37:09

标签: python c++

我使用bar_extension创建了一个python扩展distutilsbar_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

那是怎么回事?

谢谢!

0 个答案:

没有答案