0

我正在尝试在 Mac OS X 10.6.3 中安装 h5py。

首先我安装了 HDF5 1.8,它使用了以下命令:

./configure \
--prefix=/Library/Frameworks/Python.framework/Versions/Current \
--enable-shared \
--enable-production \
--enable-threadsafe \
CPPFLAGS=-I/Library/Frameworks/Python.framework/Versions/Current/include \
LDFLAGS=-L/Library/Frameworks/Python.framework/Versions/Current/lib

make
make check
sudo make install

然后安装 h5py:

/Library/Frameworks/Python.framework/Versions/Current/bin/python \
setup.py \
build \
--api=18 \
--hdf5=/Library/Frameworks/Python.framework/Versions/Current

然后我得到了错误:

******************************************
Configure: Autodetecting HDF5 settings...
    Custom HDF5 dir:       /Library/Frameworks/Python.framework/Versions/Current
    Custom API level:      (1, 8)
ld: warning: in detect/vers.o, file was built for unsupported file format which is not the architecture being linked (i386)

ld: warning: in /Library/Frameworks/Python.framework/Versions/Current/lib/libhdf5.dylib, file was built for unsupported file format which is not the architecture being linked (i386)

Undefined symbols:
  "_main", referenced from:
      start in crt1.10.5.o

ld: symbol(s) not found

collect2: ld returned 1 exit status

Failed to compile HDF5 test program.  Please check to make sure:

* You have a C compiler installed
* A development version of Python is installed (including header files)
* A development version of HDF5 is installed (including header files)
* If HDF5 is not in a default location, supply the argument --hdf5=<path>
******************************************
error: command 'cc' failed with exit status 1

我刚刚更新了我的 Xcode,我不知道这是否是因为我的 gcc 的默认设置。如果是这样,我怎样才能摆脱这个错误?

谢谢。

4

2 回答 2

1

我在尝试使用 Intel C/C++ 编译器在 Mac OS X 上构建 Python 扩展模块时遇到了类似的错误。要修复“未定义符号:_main”错误,我必须在链接器命令中添加以下内容:-bundle -undefined dynamic_lookup

您可以执行“man ld”来找出特定链接器命令的作用,但基本上您是在告诉链接器不要担心未定义的符号并在加载库时动态查找它们。

于 2010-12-12T21:16:27.007 回答
0

如果你使用 macports 试试:py26-h5py

于 2010-05-19T22:08:15.003 回答