mehdigriche / pyv8

Automatically exported from code.google.com/p/pyv8
0 stars 0 forks source link

Linker error on OSX 10.8 and Python 3 #162

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
I’ve built PyV8 under OSX 10.8 and Python 3.3 and when I try to import PyV8, 
I receive the following error:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "./PyV8.py", line 32, in <module>
    import _PyV8
ImportError: dlopen(./_PyV8.so, 2): Symbol not found: _PyClass_Type
  Referenced from: ./_PyV8.so
  Expected in: flat namespace
 in ./_PyV8.so

I had to update setup.py a little to make PyV8 compile under OSX:

include_dirs += [
    BOOST_HOME,
    os.path.join(PYTHON_HOME, 'include'),
    os.path.join(PYTHON_HOME, 'Headers'),
]

library_dirs += [
    os.path.join(BOOST_HOME, 'stage/lib'),
    os.path.join(PYTHON_HOME, 'lib'),
]

boost_lib_dir = os.path.join(BOOST_HOME, 'stage/lib')
if BOOST_STATIC_LINK:
    extra_link_args += [os.path.join(boost_lib_dir, "libboost_python-mt.a")]
else:
    libraries += boost_libs

I think the problem is that linker wasn’t able to find Python lib. I’ve 
checked my Python installation and found that `PYTHON_HOME/lib` contains the 
following files:

-rwxrwxr-x    1 root  admin  161904 Sep 29 12:21 libformw.5.dylib
lrwxr-xr-x    1 root  wheel      16 Feb  1 00:48 libformw.dylib -> 
libformw.5.dylib
-rwxrwxr-x    1 root  admin   84216 Sep 29 12:21 libmenuw.5.dylib
lrwxr-xr-x    1 root  wheel      16 Feb  1 00:48 libmenuw.dylib -> 
libmenuw.5.dylib
-rwxrwxr-x    1 root  admin  762280 Sep 29 12:21 libncursesw.5.dylib
lrwxr-xr-x    1 root  wheel      19 Feb  1 00:48 libncursesw.dylib -> 
libncursesw.5.dylib
-rwxrwxr-x    1 root  admin   50448 Sep 29 12:21 libpanelw.5.dylib
lrwxr-xr-x    1 root  wheel      17 Feb  1 00:48 libpanelw.dylib -> 
libpanelw.5.dylib
lrwxr-xr-x    1 root  wheel       9 Feb  1 00:48 libpython3.3.dylib -> ../Python
lrwxr-xr-x    1 root  wheel       9 Feb  1 00:48 libpython3.3m.dylib -> 
../Python
drwxrwxr-x    5 root  admin     170 Sep 29 12:27 pkgconfig
drwxrwxr-x  191 root  admin    6494 Sep 29 12:27 python3.3

so I added `PYTHON_HOME/lib` to `library_dirs` but still no luck.

Can you help me with proper config?

Original issue reported on code.google.com by serge....@gmail.com on 6 Feb 2013 at 8:33

GoogleCodeExporter commented 8 years ago
Please ensure your PyV8 linked with the right boost and python version, because 
Python 3.3 seems doesn't have the _PyClass_Type symbol

$ otool -L _PyV8.so 
_PyV8.so:
    /opt/local/lib/libboost_python-mt.dylib (compatibility version 0.0.0, current version 0.0.0)
    /opt/local/lib/libboost_thread-mt.dylib (compatibility version 0.0.0, current version 0.0.0)
    /opt/local/lib/libboost_system-mt.dylib (compatibility version 0.0.0, current version 0.0.0)
    /usr/lib/libstdc++.6.dylib (compatibility version 7.0.0, current version 56.0.0)
    /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 169.3.0)

$ otool -L  /opt/local/lib/libboost_python-mt.dylib
/opt/local/lib/libboost_python-mt.dylib:
    /opt/local/lib/libboost_python-mt.dylib (compatibility version 0.0.0, current version 0.0.0)
    /opt/local/Library/Frameworks/Python.framework/Versions/2.7/Python (compatibility version 2.7.0, current version 2.7.0)
    /usr/lib/libstdc++.6.dylib (compatibility version 7.0.0, current version 56.0.0)
    /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 169.3.0)

$ nm /opt/local/lib/libboost_python-mt.dylib  | grep PyClass_Type
                 U _PyClass_Type

$ nm /opt/local/Library/Frameworks/Python.framework/Versions/2.7/Python | grep 
PyClass_Type
00000000001351d8 D _PyClass_Type

Check the libraries on a Debian 6 system with Python 3.3

flier@debian6-x64:~/pyv8/build/lib.linux-x86_64-3.3$ ldd _PyV8.cpython-33m.so 
    linux-vdso.so.1 =>  (0x00007fff8b1fc000)
    librt.so.1 => /lib/librt.so.1 (0x00007fe842d54000)
    libboost_python.so.1.52.0 => /usr/local/lib/libboost_python.so.1.52.0 (0x00007fe842b01000)
    libboost_thread.so.1.52.0 => /usr/local/lib/libboost_thread.so.1.52.0 (0x00007fe8428df000)
    libboost_system.so.1.52.0 => /usr/local/lib/libboost_system.so.1.52.0 (0x00007fe8426dc000)

flier@debian6-x64:~/pyv8/build/lib.linux-x86_64-3.3$ ldd 
/usr/local/lib/libboost_python.so.1.52.0
    linux-vdso.so.1 =>  (0x00007fff95fff000)
    libutil.so.1 => /lib/libutil.so.1 (0x00007f3840659000)
    libpthread.so.0 => /lib/libpthread.so.0 (0x00007f384043d000)
    libdl.so.2 => /lib/libdl.so.2 (0x00007f3840238000)
    librt.so.1 => /lib/librt.so.1 (0x00007f3840030000)
    libstdc++.so.6 => /usr/lib/libstdc++.so.6 (0x00007f383fd1c000)
    libm.so.6 => /lib/libm.so.6 (0x00007f383fa99000)
    libgcc_s.so.1 => /lib/libgcc_s.so.1 (0x00007f383f883000)
    libc.so.6 => /lib/libc.so.6 (0x00007f383f521000)
    /lib64/ld-linux-x86-64.so.2 (0x00007f3840abe000)

flier@debian6-x64:~/pyv8/build/lib.linux-x86_64-3.3$ nm 
/usr/local/lib/libboost_python.so.1.52.0  | grep PyClass_Type
flier@debian6-x64:~/pyv8/build/lib.linux-x86_64-3.3$ nm _PyV8.cpython-33m.so  | 
grep PyClass_Type

Original comment by flier...@gmail.com on 7 Feb 2013 at 2:48

GoogleCodeExporter commented 8 years ago
➜  pyv8-read-only  python3.3 build/lib.macosx-10.7-x86_64-3.3/PyV8.py 
........................EF....F..........................
======================================================================
ERROR: testArray (__main__.TestWrapper)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "build/lib.macosx-10.7-x86_64-3.3/PyV8.py", line 1477, in testArray
    array = ctxt.eval(case[0])
IndexError: list index out of range

======================================================================
FAIL: testAutoConverter (__main__.TestWrapper)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "build/lib.macosx-10.7-x86_64-3.3/PyV8.py", line 1055, in testAutoConverter
    self.assertTrue("var_i" in attrs)
AssertionError: False is not true

======================================================================
FAIL: testDestructor (__main__.TestWrapper)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "build/lib.macosx-10.7-x86_64-3.3/PyV8.py", line 1712, in testDestructor
    self.assertTrue(owner.deleted)
AssertionError: False is not true

----------------------------------------------------------------------
Ran 57 tests in 2.192s

I'm still getting failing tests

Original comment by ndudfi...@gmail.com on 7 Feb 2013 at 5:01