[SciPy-user] Scipy weave errors: undefined symbols when importing compiled extension

David Cournapeau david at ar.media.kyoto-u.ac.jp
Fri Jul 3 03:19:36 EDT 2009


Craig Finch wrote:
> I have two computers that have almost identical Python installations,
> but one of them has problems with inline Weave code.  Here is a simple
> test script that I am using:
>
> #!/usr/bin/env python
> from scipy import weave
> input_val = 10
>
> code=r"""return_val = 10*input_val;"""
>
> print weave.inline(code, ['input_val'], headers=[], compiler='gcc')
>
> It runs successfully on one computer with the following configuration:
> Python 2.5.2 (r252:60911, Apr 17 2009, 18:42:17) 
> [GCC 4.1.1 (Gentoo 4.1.1-r3)] on linux2
> Scipy 0.7.0
> Numpy 1.3.0
>
> On the other computer, it fails with the following message:
> Traceback (most recent call last):
>   File "test.py", line 12, in <module>
>     print weave.inline(code, ['input_val'], headers=[], compiler='gcc')
>   File "/home/cfinch/lib/python2.5/site-packages/scipy/weave/inline_tools.py", line 335, in inline
>     **kw)
>   File "/home/cfinch/lib/python2.5/site-packages/scipy/weave/inline_tools.py", line 468, in compile_function
>     exec 'import ' + module_name
>   File "<string>", line 1, in <module>
> ImportError: /home/cfinch/.python25_compiled/sc_71b2502f9a0b0ca9f89b0cdc7ad3819e0.so: undefined symbol: _ZNSt8ios_base4InitD1Ev
>
> I used nm to check, and that symbol is indeed present in the compiled .so file.
>
> The configuration of this computer is:
> Python 2.5.4 (r254:67916, Apr 22 2009, 15:52:10) 
> [GCC 4.1.1 20070105 (Red Hat 4.1.1-52)] on linux2
> Scipy 0.7.0
> Numpy 1.3.0
> One
> complication is that the default compiler on this system is icc, and
> numpy distutils doesn't offer a way to force it to use gcc for
> everything.
>   

Mixing C++ compilers is difficult. Icc goes through great length to be
compatible with g++ on Linux, but it is highly version dependent. In
particular, the C++ library often causes problem, which is the case here
it seems. So you're right that you should use gcc to compile the extension.

One thing you could do is to have a script called icc which calls gcc, I
think this works if the script comes first in your path. That's an
horrible hack, though.

cheers,

David



More information about the SciPy-User mailing list