pombreda / ctypesgen

Automatically exported from code.google.com/p/ctypesgen
BSD 3-Clause "New" or "Revised" License
0 stars 0 forks source link

LibraryLoader should prefer /lib64 for 64 bit apps, but not for 32 bit #2

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
If I run a module generated by ctypesgen on a 64-bit machine, the
PosixLibraryLoader inserts both /usr/lib and /lib64 (in that order) into
the load path.  However, Fedora distributes rpms that contain both 32-bit
libraries in /usr/lib and 64-bit libraries in /lib64.  As a result, when
running in a 64-bit python, ctypesgen will load the 32-bit library, which
causes the application to crash.  I actually get this error:

  File "/usr/lib/python2.4/site-packages/mylib.py", line 393, in ?
    _libs["readline"] = load_library("readline")
  File "/usr/lib/python2.4/site-packages/mylib.py", line 192, in load_library
    return self.load(path)
  File "/usr/lib/python2.4/site-packages/mylib.py", line 208, in load
    raise ImportError,e
ImportError: /usr/lib/libreadline.so.5.1: wrong ELF class: ELFCLASS32

Additionally, my machine uses a ld.so.conf that only contains the line
include /etc/ld.so.conf.d/*
so the attempt to load ld.so.conf doesn't work.

Instead, ctypesgen should try to detect whether it is running in a 64-bit
application, and set up the correct library paths accordingly.  Or, maybe
there could be a better way for me to set the library loading path at build
time or runtime.

Original issue reported on code.google.com by michael....@gmail.com on 17 Dec 2008 at 12:06

GoogleCodeExporter commented 9 years ago
Ah, I see now that I can use -L at build time.  That's probably better.

Original comment by michael....@gmail.com on 17 Dec 2008 at 7:33

GoogleCodeExporter commented 9 years ago
The easiest thing to do would just be to check in /lib64 first, followed by 
/usr/lib.
If you have a better solution, though, let me know.

Are there any users for whom it would be a bad idea to load libraries from 
/lib64 first?

Original comment by jame...@gmail.com on 18 Dec 2008 at 2:08