Bug 8883 - Cython-generated shared library fails to load.
: Cython-generated shared library fails to load.
Status: RESOLVED INVALID
Product: PyMaemo
General
: unspecified
: All Maemo
: Unspecified normal (vote)
: ---
Assigned To: Anderson Lizardo
: general
:
:
:
:
  Show dependency tree
 
Reported: 2010-02-07 07:40 UTC by Renji Panicker
Modified: 2010-02-08 18:15 UTC (History)
1 user (show)

See Also:


Attachments


Note

You need to log in before you can comment on or make changes to this bug.


Description Renji Panicker (reporter) 2010-02-07 07:40:38 UTC
SOFTWARE VERSION:
(Settings > General > About product)
Freantle Scratchbox SDK + Nokia Binaries.

EXACT STEPS LEADING TO PROBLEM: 
1. Write a trivial .py file in the scratchbox login
2. Use cython to generate a c++ file.
3. Compile and build it into a .so file.
4. Import the module.so file in python

EXPECTED OUTCOME:
The module should import successfully.

ACTUAL OUTCOME:
We get a 'No such file or directory' error. Using ldd on the .so file shows
garbage output. Running the same ldd command a second shows different garbage
output, indicating an uninitialized pointer perhaps? Full console output is
presented below.

REPRODUCIBILITY:
(always)

EXTRA SOFTWARE INSTALLED:
None

OTHER COMMENTS:
Excat console output is as follows:

[sbox-FREMANTLE_ARMEL: ~/tmp] > echo $LD_LIBRARY_PATH
/home/renji/tmp
[sbox-FREMANTLE_ARMEL: ~/tmp] > echo $PYTHONPATH
/home/renji/tmp
[sbox-FREMANTLE_ARMEL: ~/tmp] > cat x.py
def fn():
    print 'test'

[sbox-FREMANTLE_ARMEL: ~/tmp] > cython --cplus x.py 
[sbox-FREMANTLE_ARMEL: ~/tmp] > g++ --shared -I/usr/include/python2.5/ x.cpp -o
x.so
[sbox-FREMANTLE_ARMEL: ~/tmp] > python -c "import x"
Traceback (most recent call last):
  File "<string>", line 1, in ?
ImportError: ./x.so: cannot open shared object file: No such file or directory
[sbox-FREMANTLE_ARMEL: ~/tmp] > ldd x.so
�": No such file or directory
    libstdc++.so.6 => /usr/lib/libstdc++.so.6 (0x00000000)
    libm.so.6 => /lib/libm.so.6 (0x00000000)
    libgcc_s.so.1 => /lib/libgcc_s.so.1 (0x00000000)
    libc.so.6 => /lib/libc.so.6 (0x00000000)
    h$ => �" (0x00000000)
    �" => /lib/ld-linux.so.3 (0x00000000)
    ld-linux.so.3 => /lib/ld-linux.so.3 (0x00000000)
    /lib/ld-linux.so.3 => /lib/ld-linux.so.3 (0x00000000)
Segmentation fault (core dumped)
[sbox-FREMANTLE_ARMEL: ~/tmp] > ldd x.so
��: No such file or directory
    libstdc++.so.6 => /usr/lib/libstdc++.so.6 (0x00000000)
    libm.so.6 => /lib/libm.so.6 (0x00000000)
    libgcc_s.so.1 => /lib/libgcc_s.so.1 (0x00000000)
    libc.so.6 => /lib/libc.so.6 (0x00000000)
    h� => �� (0x00000000)
    �� => /lib/ld-linux.so.3 (0x00000000)
    ld-linux.so.3 => /lib/ld-linux.so.3 (0x00000000)
    /lib/ld-linux.so.3 => /lib/ld-linux.so.3 (0x00000000)
Segmentation fault (core dumped)
[sbox-FREMANTLE_ARMEL: ~/tmp] > cython --version
Cython version 0.11.2

------------------------------------------------
On an Ubuntu desktop, the output is as expected after following the exact
sequence of steps above:
renji@shrine:~/tmp$ ldd x.so
    libstdc++.so.6 => /usr/lib/libstdc++.so.6 (0x00f02000)
    libm.so.6 => /lib/tls/i686/cmov/libm.so.6 (0x0073e000)
    libgcc_s.so.1 => /lib/libgcc_s.so.1 (0x009c6000)
    libc.so.6 => /lib/tls/i686/cmov/libc.so.6 (0x00110000)
    /lib/ld-linux.so.2 (0x00cd1000)
renji@shrine:~/tmp$ ldd x.so
    libstdc++.so.6 => /usr/lib/libstdc++.so.6 (0x00241000)
    libm.so.6 => /lib/tls/i686/cmov/libm.so.6 (0x001a1000)
    libgcc_s.so.1 => /lib/libgcc_s.so.1 (0x00a02000)
    libc.so.6 => /lib/tls/i686/cmov/libc.so.6 (0x00333000)
    /lib/ld-linux.so.2 (0x007b8000)
renji@shrine:~/tmp$ cython --version
Cython version 0.11.2

------------------------------------------------
User-Agent:       Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.7)
Gecko/20100106 Ubuntu/9.10 (karmic) Firefox/3.5.7
Comment 1 Anderson Lizardo 2010-02-08 13:02:07 UTC
A few notes:

* You should use FREMANTLE_X86 for testing on desktop. Use FREMANTLE_ARMEL only
for the final build, to build binaries for the N900.

* Use "python2.5" instead of "python". Calling just "python" will call
Scratchbox's internal python interpreter, which will NOT work.

Please try these changes and report here if it works or not. Also see
http://pymaemo.garage.maemo.org/faq.html
Comment 2 Renji Panicker (reporter) 2010-02-08 18:15:44 UTC
Anderson,

Thank you for your quick response. The problem was I was using the scratchbox
python as you indicated. Using python2.5 explicitly solved the problem.

Regards,
-/renji