我正在尝试在我的Mac上编译来自here的s-transform python包装器(Mountain Lion,从Macports安装的gcc45,通过Enthought 64位安装的Python)。
我是科学用户而不是编译器专家,虽然它在我的Linux机器上开箱即用(只需将int
更改为npy_intp
和PyArray_FromDims
PyArray_SimpleNew
),我真的不知道如何在Macbook上实现这一目标......
所以我构建了这个Makefile:
PYINCDIR = /Library/Frameworks/EPD64.framework/Versions/Current/include/python2.7
NUMPYDIR = /Library/Frameworks/EPD64.framework/Versions/Current/lib/python2.7/site-packages/numpy/core/include/numpy CFLAGS = -O3 -I$(PYINCDIR) -I$(NUMPYDIR) -fPIC
all: sinemodule.so stmodule.so
sinemodule.so: sinemodule.o $(CC) -shared -o $@ sinemodule.o
stmodule.so: stmodule.o st.o $(CC) -shared -o $@ stmodule.o st.o
-lfftw3
试图“制造”,我得到:
cc -shared -o sinemodule.so sinemodule.o
Undefined symbols for architecture x86_64:
"_PyArg_ParseTuple", referenced from:
_sine_taper_wrap in sinemodule.o
"_PyCObject_AsVoidPtr", referenced from:
_initsine in sinemodule.o
"_PyCObject_Type", referenced from:
_initsine in sinemodule.o
"_PyErr_Format", referenced from:
_initsine in sinemodule.o
"_PyErr_Print", referenced from:
_initsine in sinemodule.o
"_PyErr_SetString", referenced from:
_initsine in sinemodule.o
"_PyExc_AttributeError", referenced from:
_initsine in sinemodule.o
"_PyExc_ImportError", referenced from:
_initsine in sinemodule.o
"_PyExc_RuntimeError", referenced from:
_initsine in sinemodule.o
"_PyImport_ImportModule", referenced from:
_initsine in sinemodule.o
"_PyObject_GetAttrString", referenced from:
_initsine in sinemodule.o
"_Py_InitModule4_64", referenced from:
_initsine in sinemodule.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [sinemodule.so] Error 1
也许这是一个非常基本的事情,但说实话我甚至不知道从哪里开始阅读以修复它......
为你的帮助干杯!
答案 0 :(得分:0)
我刚发现这篇废弃的帖子,想分享我的解决方案。
首先,正如你所做的那样,你需要找到python和numpy包含你的python发行版的dirs。
在我使用Anaconda 1.9.1的情况下,这是
PYINCDIR = /Users/dengemann/anaconda/include/python2.7/include
NUMPYDIR = /Users/dengemann/anaconda/lib/python2.7/site-packages/numpy/core/include/numpy/
其次,您不能直接调用Makefile,但要确保顶级目录中的setup.py是正确的。
就我而言,达尔文'没有明确支持,所以我已经添加了它。
# linux first
if sys.platform in ['linux2', 'darwin']:
include_dirs = [os.path.join(NUMPYDIR, r'include/numpy')]
libraries=['fftw3']
library_dirs=[] # assume we use default locations
在运行python setup.py install
后进行这些修改后,作业和输出看起来与预期一致。
HTH,
丹尼斯