我在 Mac 上从源代码构建了 numpy,以将其链接到我的 ATLAS 库。因此,我想按照描述的方式运行它这里 使用以下选项:
export MACOSX_DEPLOYMENT_TARGET=10.10
export CFLAGS="-arch i386 -arch x86_64"
export FFLAGS="-m32 -m64"
export LDFLAGS="-Wall -undefined dynamic_lookup -bundle -arch i386 -arch x86_64"
export PYTHONPATH="/Library/Python/2.6/site-packages/"
但是编译器不喜欢所有这些 arch 标志并退出:
C compiler: cc -DNDEBUG -g -fwrapv -Os -Wall -Wstrict-prototypes -arch i386 -arch x86_64 -arch x86_64 -arch i386 -pipe
compile options: '-c'
cc: _configtest.c
cc _configtest.o -L/usr/local/atlas/lib -llapack -lf77blas -lcblas -latlas -o _configtest
ld: warning: ignoring file _configtest.o, file was built for i386 which is not the architecture being linked (x86_64): _configtest.o
Undefined symbols for architecture x86_64:
"_main", referenced from:
implicit entry/start for main executable
ld: symbol(s) not found for architecture x86_64
collect2: error: ld returned 1 exit status
删除 -arch i386 标志后,安装就可以正常进行了:
cc -DNDEBUG -g -fwrapv -Os -Wall -Wstrict-prototypes -arch x86_64 -pipe
但是在导入 numpy 时会导致错误:
>>> import numpy
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Library/Python/2.7/site-packages/numpy/__init__.py", line 170, in <module>
from . import add_newdocs
File "/Library/Python/2.7/site-packages/numpy/add_newdocs.py", line 13, in <module>
from numpy.lib import add_newdoc
File "/Library/Python/2.7/site-packages/numpy/lib/__init__.py", line 8, in <module>
from .type_check import *
File "/Library/Python/2.7/site-packages/numpy/lib/type_check.py", line 11, in <module>
import numpy.core.numeric as _nx
File "/Library/Python/2.7/site-packages/numpy/core/__init__.py", line 6, in <module>
from . import multiarray
ImportError: dlopen(/Library/Python/2.7/site-packages/numpy/core/multiarray.so, 2): no suitable image found. Did find:
/Library/Python/2.7/site-packages/numpy/core/multiarray.so: mach-o, but wrong architecture
我的arch
事实上是i386
并且我的machine
a x86_64h
。
这是否意味着我安装了错误的 ATLAS 或我在 numpy 构建中缺少某些内容?为什么我必须传递多个-arch
标志?