我刚刚开始使用 Cython,正在尝试编译一个“Hello World”脚本。我正在尝试使用 gcc -Os/User/Documents/Python/Test\Python/helloCopy.c -I/Library/Frameworks/Python.framework/Versions/3.5/include/python3.5m -l
,但我不知道在 -l
之后添加什么。其他论坛页面说“在链接器命令行上包含 -lpython2.7(或您使用的任何 Python 版本)”,但这会产生 ld: library not found for -lpython3.5
clang:错误:链接器命令失败,退出代码为 1(使用 -v 查看调用)
我应该将 -l
定向到特定文件夹吗?
最佳答案
我不知道你用的是什么资源,但是this没有说明任何有关 -l
标志的信息。这表明
cython -a helloCopy.pyx
This creates a yourmod.c file, and the -a switch produces an annotated html file of the source code. Pass the -h flag for a complete list of supported flags.
gcc -shared -pthread -fPIC -fwrapv -O2 -Wall -fno-strict-aliasing -I/usr/include/python2.7 -o helloCopy.so helloCopy.c
(Linux)
在 macOS 上我会尝试编译
gcc -I/usr/bin/python -o helloCopy.so helloCopy.c
使用标准版本的 Python。
关于python - Cython:编译并找不到库 Mac OSX 10.12,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43055967/