[Numpy-discussion] building 32 bit numpy on 64 bit linux
david.jones74 at gmail.com
Mon May 19 10:26:54 EDT 2014
As a follow up, here's an explanation of how to do this without pip or
virtualenv. To do it with virtualenv, just place the wrapper scripts in
your virtualenv's bin directory:
To build python:
Install python build dependencies (on Centos 6). Make sure to get the i686
tk-devel, tcl-devel, libX11-devel, libXau-devel, sqlite-devel, gdbm-devel,
readline-devel, zlib-devel, bzip2-devel, openssl-devel, krb5-devel,
ncurses-devel, valgrind-devel, valgrind, libxcb-devel, libXft-devel, tk
CFLAGS="-g -O2 -m32" LDFLAGS="-m32 -Wl,-rpath,/opt/python/ia32/
lib" ./configure --enable-unicode=ucs4 --enable-shared
To build numpy:
Install numpy dependencies:
atlas-devel, lapack-devel, blas-devel, libgfortran
Now you just need to use some compiler wrappers, so the "setup.py build"
command will append the -m32 to flag to every call to the compilers. You
need to wrap gcc and gfortran, and possibly g++ as well. Place the wrapper
scripts and a link to your python executable in a directory, e.g. ~/bin.
You could also use virtualenv to make this easier:
ln -sfn /opt/python/ia32/bin/python
touch gcc g++ gfortan
chmod u+x gcc g++ gfortran
Now edit the wrapper scripts:
#### gcc ####
/usr/bin/gcc -m32 "$@"
#### g++ ####
/usr/bin/gcc -m32 "$@"
#### gfotran ####
/usr/bin/gfortan -m32 "$@"
Add ~/bin to the front of your path:
python setup.py build
On Thu, Dec 12, 2013 at 1:58 PM, David Jones <david.jones74 at gmail.com>wrote:
> I'm trying to compile 32-bit numpy on a 64 bit Centos 6 system, but fails
> with the message:
> "Broken toolchain: cannot link a simple C program"
> It get's the compile flags right, but not the linker:
> C compiler: gcc -pthread -fno-strict-aliasing -g -O2 -m32 -DNDEBUG -g
> -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC
> 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/python/ia32/include/python2.7
> gcc: _configtest.c
> gcc -pthread _configtest.o -o _configtest
> _configtest.o: could not read symbols: File in wrong format
> collect2: ld returned 1 exit status
> I'm bulding it using a 32bit python build that I compiled on the same
> I tried:
> OPT="-m32" FOPT="-m32" python setup.py build
> setarch x86_64 -B python setup.py build
> But with the same results.
> Someone worked around this by altering ccompiler.py, but I'm trying to
> find a cleaner solution.
> Is there a standard way of doing this?
> David J.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the NumPy-Discussion