Csound Csound-dev Csound-tekno Search About

[Csnd] Re: Re: Re: Re: Re: can't import csnd from python

Date2007-11-06 02:25
From"Michael Gogins"
Subject[Csnd] Re: Re: Re: Re: Re: can't import csnd from python
The nm output tells us that _csnd.so does indeed define csoundSetKillXYinCallback. U means 'undefined' and 'T' means 'program text,' which means 'defined.'
 
The ldd output suggests that _csnd.so is not finding csound32.so.5.1 or csound64.so.5.1.
 
Probably all you need to do is add something to your shell initialization script to add your Csound bin directory (assuming it contains the shared libraries and python file mentioned below) to LD_LIBRARY_PATH and to your PYTHONPATH.
 
Regards,
Mike
 
As I mentioned before, the hierarchy of libraries is as follows. All of the .so files have to be in your ldconfig or in a LD_LIBRARY_PATH environment variable. All of the .pyd files (for Python 2.5) or _XXX.so files (for earlier versions of Python) and corresponding .py files have to be in Python's site-packages directory, or in a PYTHONPATH environment variable. If you are not using CsoundAC you can stop with csnd.py. On Linux, just substitute .so for .dll.
 
csound64.dll.5.1, the Csound C API shared library, in other words Csound
proper, which is dynamically linked to by...

csnd.dll, which implements CppSound, a C++ wrapper for the Csound C API,
which also includes the ability to load and save Csound files to and from
internal storage, pick arrangements out of Csound orchestras, and so on,
which is dynamically linked to by CsoundAC.dll and also by...

_csnd.pyd, SWIG-generated C stubs for CppSound, in other words, a low-level
procedural Python extension module for CppSound named _csnd, which is dynamically LOADED by...

csnd.py, SWIG-generated Python class proxies for _csnd, in other words, a
high-level object-oriented Python extension module for CppSound named csnd,
which is loaded by Python scripts that use Csound;

CsoundAC.dll, a C++ class library for algorithmic composition (which also
links with csnd.dll), which is dynamically linked to by...

_CsoundAC.pyd, SWIG-generated C stubs for the classes in CsoundAC, in other
words, a low-level procedural Python extension module for the CsoundAC
classes named _CsoundAC, which is dynamically LOADED by...

CsoundAC.py, SWIG-generated Python class proxies for _CsoundAC, in other
words, a high-level object-oriented Python extension module for the CsoundAC
classes named CsoundAC, which is loaded by Python scripts that use CsoundAC.
----- Original Message -----
Sent: Monday, November 05, 2007 8:42 PM
Subject: [Csnd] Re: Re: Re: Re: can't import csnd from python

Thanks John for your response.

Sorry, I'm not sure which ones are those correct files. I did a nm in some of the libraries and got this:

$ nm /usr/lib/python2.5/site-packages/_csnd.so | grep csoundSetKillXYinCallback
         U csoundSetKillXYinCallback

$ nm /usr/local/lib/libcsnd.so.5.1 | grep csoundSetKillXYinCallback
000f57d0 T csoundSetKillXYinCallback

$ nm /usr/local/lib/libcsnd.so.5.1 | grep csoundSetKillXYinCallback
000f57d0 T csoundSetKillXYinCallback

... and ldd:

$ ldd /usr/lib/python2.5/site-packages/_csnd.so
        linux-gate.so.1 =>  (0xb7f4d000)
        libpython2.5.so.1.0 => /usr/lib/libpython2.5.so.1.0 (0xb7d45000)
        liblua-5.1.so => /usr/lib/liblua-5.1.so (0xb7d1b000)
        libstdc++.so.6 => /usr/lib/libstdc++.so.6 (0xb7c30000)
        libutil.so.1 => /lib/libutil.so.1 (0xb7c2c000)
        libsndfile.so.1 => /usr/lib/libsndfile.so.1 (0xb7bcc000)
        libdl.so.2 => /lib/libdl.so.2 (0xb7bc7000)
        libpthread.so.0 => /lib/libpthread.so.0 (0xb7baf000)
        libm.so.6 => /lib/libm.so.6 (0xb7b86000)
        libgcc_s.so.1 => /lib/libgcc_s.so.1 (0xb7b7a000)
        libc.so.6 => /lib/libc.so.6 (0xb7a26000)
        /lib/ld-linux.so.2 (0x80000000)

$ ldd /usr/local/lib/libcsnd.so.5.1
        linux-gate.so.1 =>  (0xb7f0c000)
        libpython2.5.so.1.0 => /usr/lib/libpython2.5.so.1.0 (0xb7c55000)
        liblua-5.1.so => /usr/lib/liblua-5.1.so (0xb7c2b000)
        libstdc++.so.6 => /usr/lib/libstdc++.so.6 (0xb7b40000)
        libutil.so.1 => /lib/libutil.so.1 (0xb7b3c000)
        libsndfile.so.1 => /usr/lib/libsndfile.so.1 (0xb7adc000)
        libdl.so.2 => /lib/libdl.so.2 (0xb7ad7000)
        libpthread.so.0 => /lib/libpthread.so.0 (0xb7abf000)
        libm.so.6 => /lib/libm.so.6 (0xb7a96000)
        libgcc_s.so.1 => /lib/libgcc_s.so.1 (0xb7a8a000)
        libc.so.6 => /lib/libc.so.6 (0xb7936000)
        /lib/ld-linux.so.2 (0x80000000)

Is this information any useful?


Thanks!


Hector


On Nov 5, 2007 12:12 PM, <jpff@cs.bath.ac.uk> wrote:


On Mon, 5 Nov 2007, Hector Centeno wrote:

> > >
> > >$ python
> > >Python 2.5 (r25:51908, Oct 19 2007, 09:47:40)
> > >[GCC 4.1.2 20070925 (Red Hat 4.1.2-27)] on linux2
> > >Type "help", "copyright", "credits" or "license" for more information.
> > > >>> import csnd
> > >Traceback (most recent call last):
> > >   File "<stdin>", line 1, in <module>
> > >   File "/usr/lib/python2.5/site-packages/csnd.py", line 7, in <module>
> > >     import _csnd
> > >ImportError: /usr/lib/python2.5/site-packages/_csnd.so: undefined symbol:
> > >csoundSetKillXYinCallback
> > >
> > >

I do not use python, but I do know that csoundSetKillXYinCallback
is defined in Top/csound.c so use of nm and ldd on the correct files might
say where it has gone

==John