开发者

How to build 32bit python 2.6 on 64bit Linux?

I'm stuck for a full afternoon now trying to get python to build in 32bit mode. I run a 64bit Linux machine with openSUSE 11.3, I have the necessary -devel and -32bit packages installed to build applications in 32bit mode.

The problem with the python build seems to be not in the make run itself, but in the afterwards run of setup.py, invoked by make.

I found the following instructions for Ubuntu Linux: h**p://indefinitestudies.org/2010/02/08/how-to-build-32-bit-python-on-ubuntu-9-10-x86_64/

When I do as described, I get the following output:

http://pastebin.com/eP8WJ8V4

But I have the -32bit packages of libreadline, libopenssl, etc.pp. installed, but of course, they reside under /lib and /usr/lib and not /lib64 and /usr/lib64.

When I start the python binary that results from this build, i get:

./python
Python 2.6.6 (r266:84292, Oct  5 2010, 21:22:06) 
[GCC 4.5.0 20100604 [gcc-4_5-branch revision 160292]] on linux2
Type "help", "copyright", "credits" or "license" for more information.
Traceback (most recent call last):
  File "/etc/pythonstart", line 7, in <module>
    import readline
ImportError: No module named readline

So how to get 开发者_运维百科setup.py to observe the LDFLAGS=-L/lib command??

Any help is greatly appreciated.

Regards, Philipp


You'll need to pass the appropriate flags to gcc and ld to tell the compiler to compile and produce 32bit binaries.

Use --build and --host.

./configure --help
System types:
  --build=BUILD     configure for building on BUILD [guessed]
  --host=HOST       cross-compile to build programs to run on HOST [BUILD]

You need to use ./configure --build=x86_64-pc-linux-gnu --host=i686-pc-linux-gnu to compile for 32-bit Linux in a 64-bit Linux system.

Note: You still need to add the other ./configure options.


Regarding why, since Kirk (and probably others) wonder, here is an example: I have a Python app with large dicts of dicts containing light-weight objects. This consumes almost twice as much RAM on 64bit as on 32bit simply due to the pointers. I need to run a few instances of 2GB (32bit) each and the extra RAM quickly adds up. For FreeBSD, a detailed recipe for 32bit-on-64bit jail is here http://www.gundersen.net/32bit-jail-on-64bit-freebsd/

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜