0

背景

使用带有第二代 Core i7 处理器的 2012 iMac,我正在尝试在 OSX 10.8.3 上构建NumPy 1.7.0 (最终是 SciPY),该 OSX 10.8.3 链接到英特尔C++ Composer XE 2013Fortran评估版本中包含的MKL适用于 OSX 的Composer XE 2013。我正在关注英特尔网站上的这篇文章(松散地改编,因为在某些情况下它不是很具体),用于设置、编译器标志等。

问题

使用任一:

$ python3 setup.py config build --compiler=intelem --fcompiler=intelem

或者

$ python3 setup.py config --compiler=intelem --fcompiler=intelem build_clib --compiler=intelem --fcompiler=intelem build_ext --compiler=intelem --fcompiler=intelem

我犯了同样的错误:

running build_clib
customize IntelEM64TCCompiler
customize IntelEM64TCCompiler using build_clib
running build_ext
customize IntelEM64TCCompiler
customize IntelEM64TCCompiler using build_ext
building 'numpy.core._dummy' extension
compiling C sources
C compiler: icc -m64 -march=corei7 -O3 -g -fPIC -fp-model strict -fomit-frame-pointer -openmp -xhost -DMKL_ILP64 -I/opt/intel/mkl/include

compile options: '-Inumpy/core/include -Ibuild/src.macosx-10.8-x86_64-3.3/numpy/core/include/numpy -Inumpy/core/src/private -Inumpy/core/src -Inumpy/core -Inumpy/core/src/npymath -Inumpy/core/src/multiarray -Inumpy/core/src/umath -Inumpy/core/src/npysort -Inumpy/core/include -I/opt/local/Library/Frameworks/Python.framework/Versions/3.3/include/python3.3m -Ibuild/src.macosx-10.8-x86_64-3.3/numpy/core/src/multiarray -Ibuild/src.macosx-10.8-x86_64-3.3/numpy/core/src/umath -c'
icc: numpy/core/src/dummymodule.c
icc: command line warning #10121: overriding '-marchcorei7' with '-xhost'
icc -m64 -march=corei7 -O3 -g -fPIC -fp-model strict -fomit-frame-pointer -openmp -xhost -DMKL_ILP64 -I/opt/intel/mkl/include -shared build/temp.macosx-10.8-x86_64-3.3/numpy/core/src/dummymodule.o -Lbuild/temp.macosx-10.8-x86_64-3.3 -o build/lib.macosx-10.8-x86_64-3.3/numpy/core/_dummy.so
icc: command line warning #10121: overriding '-marchcorei7' with '-xhost'
icc: command line warning #10006: ignoring unknown option '-shared'
Undefined symbols for architecture x86_64:
  "_PyModule_Create2", referenced from:
      _PyInit__dummy in dummymodule.o
  "_main", referenced from:
      start in crt1.10.6.o
ld: symbol(s) not found for architecture x86_64
icc: command line warning #10121: overriding '-marchcorei7' with '-xhost'
icc: command line warning #10006: ignoring unknown option '-shared'
Undefined symbols for architecture x86_64:
  "_PyModule_Create2", referenced from:
      _PyInit__dummy in dummymodule.o
  "_main", referenced from:
      start in crt1.10.6.o
ld: symbol(s) not found for architecture x86_64
error: Command "icc -m64 -march=corei7 -O3 -g -fPIC -fp-model strict -fomit-frame-pointer -openmp -xhost -DMKL_ILP64 -I/opt/intel/mkl/include -shared build/temp.macosx-10.8-x86_64-3.3/numpy/core/src/dummymodule.o -Lbuild/temp.macosx-10.8-x86_64-3.3 -o build/lib.macosx-10.8-x86_64-3.3/numpy/core/_dummy.so" failed with exit status 1

我的LD_LIBRARY_PATHDYLD_LIBRARY_PATH都是:

/opt/intel/lib/intel64:/opt/intel/lib:/opt/intel/mkl/lib:/opt/local/Library/Frameworks/Python.framework/Versions/3.3/lib:/opt/local/lib:/usr/local/lib:/usr/lib

DYLD_FRAMEWORK_PATH的是:

/opt/local/Library/Frameworks:/Library/Frameworks:/System/Library/Frameworks

site.cfg的是:

[DEFAULT]
library_dirs = /opt/intel/lib/intel64:/opt/intel/lib:/opt/intel/mkl/lib:/opt/local/Library/Frameworks/Python.framework/Versions/3.3/lib:/opt/local/lib:/usr/local/lib:/usr/lib
include_dirs = /opt/intel/include:/opt/intel/include/intel64:/opt/intel/mkl/include:/opt/local/Library/Frameworks/Python.framework/Versions/3.3/include/python3.3m:/opt/local/include:/usr/local/include:/usr/include

[mkl]
library_dirs = /opt/intel/lib/intel64:/opt/intel/lib:/opt/intel/mkl/lib:/opt/local/Library/Frameworks/Python.framework/Versions/3.3/lib:/opt/local/lib:/usr/local/lib:/usr/lib
include_dirs = /opt/intel/include:/opt/intel/include/intel64:/opt/intel/mkl/include:/opt/local/Library/Frameworks/Python.framework/Versions/3.3/include/python3.3m:/opt/local/include:/usr/local/include:/usr/include
mkl_libs = mkl_rt
lapack_libs = mkl_lapack

指向iccifort在其中的符号链接是/usr/bin有功能的。的内容dummymodule.c可在GitHub 上的 numpy 存储库中找到。我不是 C 程序员,所以我不能立即看出问题所在。我使用 MacPorts python 3.3.0(使用上述设置)和 python.org 3.3.0 都遇到了这个错误,设置修改为指向它而不是/opt/local.

恳求

任何人都可以帮助解决这个问题吗?

编辑

我换成了-shared-dynamiclib现在得到:

building extension "numpy.random.mtrand" sources
C compiler: icc -m64 -O3 -g -fPIC -fp-model strict -fomit-frame-pointer -openmp -xhost -DMKL_ILP64

compile options: '-Inumpy/core/src/private -Inumpy/core/src -Inumpy/core -Inumpy/core/src/npymath -Inumpy/core/src/multiarray -Inumpy/core/src/umath -Inumpy/core/src/npysort -Inumpy/core/include -I/opt/local/Library/Frameworks/Python.framework/Versions/3.3/include/python3.3m -c'
icc: _configtest.c
icc -m64 -O3 -g -fPIC -fp-model strict -fomit-frame-pointer -openmp -xhost -DMKL_ILP64 _configtest.o -o _configtest
_configtest
failure.
removing: _configtest.c _configtest.o _configtest
building data_files sources
build_src: building npy-pkg config files
running build_py
copying numpy/version.py -> build/lib.macosx-10.8-x86_64-3.3/numpy
copying build/src.macosx-10.8-x86_64-3.3/numpy/__config__.py -> build/lib.macosx-10.8-x86_64-3.3/numpy
copying numpy/distutils/intelccompiler.py -> build/lib.macosx-10.8-x86_64-3.3/numpy/distutils
copying build/src.macosx-10.8-x86_64-3.3/numpy/distutils/__config__.py -> build/lib.macosx-10.8-x86_64-3.3/numpy/distutils
copying numpy/distutils/fcompiler/intel.py -> build/lib.macosx-10.8-x86_64-3.3/numpy/distutils/fcompiler
running build_clib
customize IntelEM64TCCompiler
customize IntelEM64TCCompiler using build_clib
running build_ext
customize IntelEM64TCCompiler
customize IntelEM64TCCompiler using build_ext
building 'numpy.core._dummy' extension
compiling C sources
C compiler: icc -m64 -O3 -g -fPIC -fp-model strict -fomit-frame-pointer -openmp -xhost -DMKL_ILP64

compile options: '-Inumpy/core/include -Ibuild/src.macosx-10.8-x86_64-3.3/numpy/core/include/numpy -Inumpy/core/src/private -Inumpy/core/src -Inumpy/core -Inumpy/core/src/npymath -Inumpy/core/src/multiarray -Inumpy/core/src/umath -Inumpy/core/src/npysort -Inumpy/core/include -I/opt/local/Library/Frameworks/Python.framework/Versions/3.3/include/python3.3m -c'
icc: numpy/core/src/dummymodule.c
icc -m64 -O3 -g -fPIC -fp-model strict -fomit-frame-pointer -openmp -xhost -DMKL_ILP64 -dynamiclib build/temp.macosx-10.8-x86_64-3.3/numpy/core/src/dummymodule.o -Lbuild/temp.macosx-10.8-x86_64-3.3 -o build/lib.macosx-10.8-x86_64-3.3/numpy/core/_dummy.so
Undefined symbols for architecture x86_64:
  "_PyModule_Create2", referenced from:
      _PyInit__dummy in dummymodule.o
ld: symbol(s) not found for architecture x86_64
Undefined symbols for architecture x86_64:
  "_PyModule_Create2", referenced from:
      _PyInit__dummy in dummymodule.o
ld: symbol(s) not found for architecture x86_64
error: Command "icc -m64 -O3 -g -fPIC -fp-model strict -fomit-frame-pointer -openmp -xhost -DMKL_ILP64 -dynamiclib build/temp.macosx-10.8-x86_64-3.3/numpy/core/src/dummymodule.o -Lbuild/temp.macosx-10.8-x86_64-3.3 -o build/lib.macosx-10.8-x86_64-3.3/numpy/core/_dummy.so" failed with exit status 1

所以,我failure.在 _configtest (不确定那是什么)和下面的相同错误之后得到一条线。想法?

4

2 回答 2

3

icc:命令行警告#10006:忽略未知选项“-shared”

这是一个问题。您的编译器正在尝试构建一个可执行文件,即使它被告知要构建一个共享库。根据 icc 文档,-shared仅在 Linux 系统上可用。由于您的系统是 MacOSX 系统,因此我认为您想-dynamiclib改用它。

编辑:我怀疑您缺少指向 pylib 的链接,位于:icc -m64 -O3 -g -fPIC -fp-model strict -fomit-frame-pointer -openmp -xhost -DMKL_ILP64 -dynamiclib build/temp.macosx-10.8-x86_64-3.3/numpy/core/src/dummymodule.o -Lbuild/temp.macosx-10.8-x86_64-3.3 -o build/lib.macosx-10.8-x86_64-3.3/numpy/core/_dummy.so

缺少的链接会导致:

Undefined symbols for architecture x86_64:
  "_PyModule_Create2", referenced from:
      _PyInit__dummy in dummymodule.o
ld: symbol(s) not found for architecture x86_64

您需要添加-lpythonX.Y,其中 XY 表示您要链接的 Python 版本。如果此文件存在,但链接器找不到它,则需要使用-Llink/search/directory(例如-Llib/)指令告诉链接器它在哪里。如果文件不存在,则需要构建它。

于 2013-04-01T15:54:54.787 回答
1

我建议您将文件 numpy-1.7.0/numpy/distutils/intelccompiler.py 第 37 行更改为

icc -m64 -fPIC -O3 -g -fPIC -fp-model strict -fomit-frame-pointer -openmp -xhost -undefined dynamic_lookup -bundle -DMKL_ILP64

这对我有用,我之前有这个编译错误

于 2013-09-11T08:04:08.877 回答