我正在构建/编译Cython项目:
setup.caller.py
from distutils.core import setup
from distutils.extension import Extension
from Cython.Distutils import build_ext
from Cython.Build import cythonize
setup(
name = 'test app',
cmdclass = {'build_ext': build_ext},
ext_modules = cythonize([
Extension(
'caller',
['caller.pyx', 'foo.cpp'],
language='c++',
extra_compile_args=['-std=c++11'],
library_dirs=['/usr/lib/bar'],
libraries=['libbar'],
include_dirs=['/usr/include/baz']
)
])
)
但是当我构建/编译时出现错误:
$ python setup.caller.py build_ext --inplace
...
/usr/bin/ld: cannot find -llibbar
collect2: error: ld returned 1 exit status
error: command 'x86_64-linux-gnu-g++' failed with exit status 1
我检查过,“libbar.so”在“/ usr / lib / bar”中。我在Linux Mint上编译。
答案 0 :(得分:2)
我认为它应该只是bar
而不是libbar
,链接器知道添加lib
前缀以及需要的后缀(.a
或.so
)