Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

like image 710
Philipp Avatar asked Oct 05 '10 19:10

Philipp


People also ask

How do I convert Python 32-bit to 64-bit?

No, it is not possible to upgrade a 32bit Python installation to a 64bit one. Still, there is something that you can do in order to speedup installation of a new 64bit version. Run pip freeze > packages. txt on the old installation in order to generate a list of all installed packages and their versions.

Does 32-bit Python work on 64bit?

Windows users can run 32-bit editions of Python on 64-bit Windows, but at a slight cost of performance. 32-bit Python, and 32-bit apps generally, can access only 4GB of memory at a time.

Can 32-bit programs run on 64-bit Linux?

While 64-bit apps couldn't work on 32-bit OS, 32-bit apps could work on 64-bit OS but they need some 32-bit libraries to run. Since Ubuntu 11.04 (Natty) and Debian 7.0 (Wheezy) there has been support for multiarch, when 32-bit and 64-bit libraries could live on the same OS.


1 Answers

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.

like image 139
James Mills Avatar answered Sep 24 '22 02:09

James Mills