如何在x86_64主机上使用Setup.py构建32位Python模块分发版
我需要编译一个32位的 PyEphem 版本。看起来这应该不难,但我遇到了一些编译器的问题。
$ CFLAGS=-m32 python setup.py bdist -p i386
running bdist
running bdist_dumb
running build
running build_py
running build_ext
building 'ephem._libastro' extension
gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -m32 -fPIC -Ilibastro-3.7.3 -I/usr/include/python2.6 -c extensions/_libastro.c -o build/temp.linux-x86_64-2.6/extensions/_libastro.o
In file included from /usr/include/python2.6/Python.h:58,
from extensions/_libastro.c:3:
/usr/include/python2.6/pyport.h:685:2: error: #error "LONG_BIT definition appears wrong for platform (bad gcc/glibc config?)."
error: command 'gcc' failed with exit status 1
我的构建系统是在Ubuntu 10.04上运行的。请问,Python的头文件和本地机器的架构有关系吗?
更新:我找到了一些关于 Python交叉编译 的有趣信息。
1 个回答
1
你在你的电脑上安装了32位的Python吗?我觉得如果你是用32位的Python来运行的话,应该没问题,记得要链接到正确的python.h文件。
我自己从来没有在Linux上尝试过交叉编译,但我在64位的Windows上编译过不同版本的Python,它们是并排安装的。
当然,还有一个极端的办法,就是安装一个32位的虚拟机,然后在里面进行编译。