我在 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
事實上,我的isi386
和我的machine
a x86_64h
。
這是否意味著我安裝了錯誤的 ATLAS 或者我在 numpy 建置中遺漏了某些內容?為什麼我必須傳遞多個-arch
標誌?