k***r 发帖数: 4260 | 1 I have a shared library file (.so) that I used to call with ctypes.
And that works perfectly on 32 bit Linux. However on this new
64 bit Linux, Python always compiles to 64 bit and ctypes can
not load the 32 bit .so.
The .so uses a 32 bit .a file that I don't have source for,
so I can not compile it to 64 bit.
I tried copying the 32 bit python executable to the 64 bit machine.
However, it loads the 64 bit libraries in /usr/local/lib/python2.5.
I can copy the lib files from the 32 bit machine, to | t****t 发帖数: 6806 | 2 install 32-bit python and ALL the dependencies in another directory, e.g. /
usr/local32
【在 k***r 的大作中提到】 : I have a shared library file (.so) that I used to call with ctypes. : And that works perfectly on 32 bit Linux. However on this new : 64 bit Linux, Python always compiles to 64 bit and ctypes can : not load the 32 bit .so. : The .so uses a 32 bit .a file that I don't have source for, : so I can not compile it to 64 bit. : I tried copying the 32 bit python executable to the 64 bit machine. : However, it loads the 64 bit libraries in /usr/local/lib/python2.5. : I can copy the lib files from the 32 bit machine, to
| k***r 发帖数: 4260 | 3 If I compile from source, it always compiles to 64 bit.
So I guess I'll need to install 32 bit binaries. If I
install with RPM, doesn't it always go to the default
directories? Or is there a way for me to specify that?
e.g. /
【在 t****t 的大作中提到】 : install 32-bit python and ALL the dependencies in another directory, e.g. / : usr/local32
| t****t 发帖数: 6806 | 4 you don't have to compile to 64bit. e.g. for gcc, you can specifiy -m32 to
compile to 32bit. make sure you have 32bit devel environment installed, such
as glibc-devel.i386 for fedora. the 32bit runtime (e.g. glibc.i386/glibc.
i686) is usually installed by default.
i only use fedora, the package name could be different for other
distributions.
【在 k***r 的大作中提到】 : If I compile from source, it always compiles to 64 bit. : So I guess I'll need to install 32 bit binaries. If I : install with RPM, doesn't it always go to the default : directories? Or is there a way for me to specify that? : : e.g. /
| k***r 发帖数: 4260 | 5 Thanks. That sounds like a lot of work :)
I tried a different approach, which isn't trivial either.
I compile python with
--prefix=/usr/local32 --libdir=/usr/local32/lib
Then create /usr/local32 and copy the files over to the
64 bit machine. Python runs now, although I still need
to copy all necessary files, and set LD_LIBRARY_PATH to
make the necessary modules work.
m32 to
installed, such
glibc.i386/glibc.
【在 t****t 的大作中提到】 : you don't have to compile to 64bit. e.g. for gcc, you can specifiy -m32 to : compile to 32bit. make sure you have 32bit devel environment installed, such : as glibc-devel.i386 for fedora. the 32bit runtime (e.g. glibc.i386/glibc. : i686) is usually installed by default. : i only use fedora, the package name could be different for other : distributions.
| t****t 发帖数: 6806 | 6 what's the difference...? you can do this on any 64-bit linux by specify the
same configure cmdline, while setting environment "CC=gcc -m32".
BTW, I remember the /usr/local/lib always has 32-bit libraries by default.
64-bit libraries stayes in /usr/local/lib64. You can check with "file".
【在 k***r 的大作中提到】 : Thanks. That sounds like a lot of work :) : I tried a different approach, which isn't trivial either. : I compile python with : --prefix=/usr/local32 --libdir=/usr/local32/lib : Then create /usr/local32 and copy the files over to the : 64 bit machine. Python runs now, although I still need : to copy all necessary files, and set LD_LIBRARY_PATH to : make the necessary modules work. : : m32 to
| k***r 发帖数: 4260 | 7 The difference is, I wasn't sure (still am not) what I need
to install on the 64 bit machine to compile. I use python's
configure and make and I didn't really want to mess with
the generated Makefile. Maybe it's easy. Maybe I should give
it a try next time.
It seems that in my case, the /usr/local/lib/python2.5 files
are all for 64 bit. I checked with file and confirmed this.
specify the
default.
"file".
【在 t****t 的大作中提到】 : what's the difference...? you can do this on any 64-bit linux by specify the : same configure cmdline, while setting environment "CC=gcc -m32". : BTW, I remember the /usr/local/lib always has 32-bit libraries by default. : 64-bit libraries stayes in /usr/local/lib64. You can check with "file".
| t****t 发帖数: 6806 | 8 it's rarely need to mess with the "configure" generated Makefile.
in your case, you can do
configure --prefix=/usr/local32
env CC="gcc -m32" make
make install
also, i believe */lib/python2.*/* is so called python byte-compiled file and
doesn't matter whether it's 32-bit or 64-bit...
【在 k***r 的大作中提到】 : The difference is, I wasn't sure (still am not) what I need : to install on the 64 bit machine to compile. I use python's : configure and make and I didn't really want to mess with : the generated Makefile. Maybe it's easy. Maybe I should give : it a try next time. : It seems that in my case, the /usr/local/lib/python2.5 files : are all for 64 bit. I checked with file and confirmed this. : : specify the : default.
| k***r 发帖数: 4260 | 9 I see. I didn't know the env option. Good to know that.
Inside pyton2.*/lib-dynload there are a whole bunch of
.so files.
file and
【在 t****t 的大作中提到】 : it's rarely need to mess with the "configure" generated Makefile. : in your case, you can do : configure --prefix=/usr/local32 : env CC="gcc -m32" make : make install : also, i believe */lib/python2.*/* is so called python byte-compiled file and : doesn't matter whether it's 32-bit or 64-bit...
|
|