Csound Csound-dev Csound-tekno Search About

[Cs-dev] Dynamic libcsound breaks python binding

Date2009-01-03 17:09
FromCarlosJP
Subject[Cs-dev] Dynamic libcsound breaks python binding
Hi all,

when building with dynamicCsoundLibrary=1, python binding is unable to
resolve some symbols:

[carlos@carlos tmp]$ python -c "import csnd"
Traceback (most recent call last):
  File "", line 1, in 
  File "/usr/lib/python2.6/site-packages/csnd.py", line 7, in 
    import _csnd
ImportError: /usr/lib/libcsnd.so.5.2: undefined symbol:
csoundInitTimerStruct

I've tracked down the issue to find out that it's related to the use of
soname=libcsound.so.5.2 while linking _csnd.so:

> g++ -o _csnd.so -Wl,-Bdynamic -Wl,-rpath-link,. -shared
> -Wl,-soname=libcsound.so.5.2 interfaces/python_interface_wrap.os
> -L/usr/local/lib -L/usr/lib -L/usr/lib/python2.6/config -L. -L.
> -L/usr/local/lib -L. -L. -L/usr/lib/fltk-1.1 -lpython2.6 -llua -lstdc++
> -lutil -lsndfile libcsound.so.5.2 -lsndfile -lpthread -lpthread -lm
> -lportaudio -lfltk -lasound -llo -lsndfile -ldl -lm -lpthread
> libcsnd.so.5.2

Removing that part, the problem is fixed:

> g++ -o _csnd.so -Wl,-Bdynamic -Wl,-rpath-link,. -shared 
> interfaces/python_interface_wrap.os -L/usr/local/lib -L/usr/lib
> -L/usr/lib/python2.6/config -L. -L. -L/usr/local/lib -L. -L.
> -L/usr/lib/fltk-1.1 -lpython2.6 -llua -lstdc++ -lutil -lsndfile -lsndfile
> -lpthread -lpthread -lm -lportaudio -lfltk -lasound -llo -lsndfile -ldl
> -lm -lpthread libcsnd.so.5.2

> cp _csnd.so /usr/lib/python2.6/site-packages/

> python -c "import csnd"

OK

Do you think this fix could result in other problems? For now I've just
modified SConstruct this way, at line 1115:

< tmp += ['-Wl,-soname=%s' % libName2]
> # tmp += ['-Wl,-soname=%s' % libName2]

Please, tell me what do you think. I'm maintaining the archlinux csound5
package and I don't want to introduce subtle bugs that I'm not aware of.

Best regards
-Carlos




-- 
View this message in context: http://www.nabble.com/Dynamic-libcsound-breaks-python-binding-tp21266916p21266916.html
Sent from the Csound - Dev mailing list archive at Nabble.com.


------------------------------------------------------------------------------
_______________________________________________
Csound-devel mailing list
Csound-devel@lists.sourceforge.net

Date2009-01-03 17:39
FromCarlosJP
SubjectRe: [Cs-dev] Dynamic libcsound breaks python binding
Here is some info about my system that could be relevant:

> ls -l /usr/lib/libcs*

/usr/lib/libcsnd.so -> libcsnd.so.5.2
/usr/lib/libcsnd.so.5.2
/usr/lib/libcsound.so -> libcsound.so.5.2
/usr/lib/libcsound.so.5.2

> ldd /usr/lib/python2.6/site-packages/_csnd.so  | grep libcs

libcsnd.so.5.2 => /usr/lib/libcsnd.so.5.2 (0xb78d4000)

That seems ok. From the command line given in my previous post, we can see
that _csnd is linked against both libcsnd and libcsound. I'm not an expert,
but I guess that just libcsnd (which is itself linked against libcsound) is
needed by _csnd. In fact, removing libcsound from the command:

g++ -o _csnd.so -Wl,-Bdynamic -Wl,-rpath-link,. -shared 
interfaces/python_interface_wrap.os -L/usr/local/lib -L/usr/lib
-L/usr/lib/python2.6/config -L. -L. -L/usr/local/lib -L. -L.
-L/usr/lib/fltk-1.1 -lpython2.6 -llua -lstdc++ -lutil -lsndfile -lsndfile
-lpthread -lpthread -lm -lportaudio -lfltk -lasound -llo -lsndfile -ldl -lm
-lpthread libcsnd.so.5.2

builds a working _csnd.so module which is able to run, at least,
interfaces/test.py.

Then, reintroducing soname, but this time for libcsnd:

 g++ -o _csnd.so -Wl,-Bdynamic -Wl,-rpath-link,. -shared 
-Wl,-soname=libcsnd.so.5.2 interfaces/python_interface_wrap.os
-L/usr/local/lib -L/usr/lib -L/usr/lib/python2.6/config -L. -L.
-L/usr/local/lib -L. -L. -L/usr/lib/fltk-1.1 -lpython2.6 -llua -lstdc++
-lutil -lsndfile -lsndfile -lpthread -lpthread -lm -lportaudio -lfltk
-lasound -llo -lsndfile -ldl -lm -lpthread libcsnd.so.5.2

breaks the module again:

 python -c "import csnd"
Traceback (most recent call last):
  File "", line 1, in 
  File "/usr/lib/python2.6/site-packages/csnd.py", line 7, in 
    import _csnd
ImportError: /usr/lib/python2.6/site-packages/_csnd.so: undefined symbol:
_ZN17CsoundUtilityList5CountEv

I'm really lost at this point :(. As you can see usr/lib/libcsnd.so.5.2 is
where it's supposed to be, but despite of this the linker fails to resolved
symbols defined by it when an specific version is required by means of a
soname, while the resolution succeed if the soname is omitted.

>  grep ZN17CsoundUtilityList5CountEv /usr/lib/libcsnd.so
Binary file /usr/lib/libcsnd.so matches

Any help will be greatly appreciated.

Best regards
-Carlos






CarlosJP wrote:
> 
> Hi all,
> 
> when building with dynamicCsoundLibrary=1, python binding is unable to
> resolve some symbols:
> 
> [carlos@carlos tmp]$ python -c "import csnd"
> Traceback (most recent call last):
>   File "", line 1, in 
>   File "/usr/lib/python2.6/site-packages/csnd.py", line 7, in 
>     import _csnd
> ImportError: /usr/lib/libcsnd.so.5.2: undefined symbol:
> csoundInitTimerStruct
> 
> I've tracked down the issue to find out that it's related to the use of
> soname=libcsound.so.5.2 while linking _csnd.so:
> 
>> g++ -o _csnd.so -Wl,-Bdynamic -Wl,-rpath-link,. -shared
>> -Wl,-soname=libcsound.so.5.2 interfaces/python_interface_wrap.os
>> -L/usr/local/lib -L/usr/lib -L/usr/lib/python2.6/config -L. -L.
>> -L/usr/local/lib -L. -L. -L/usr/lib/fltk-1.1 -lpython2.6 -llua -lstdc++
>> -lutil -lsndfile libcsound.so.5.2 -lsndfile -lpthread -lpthread -lm
>> -lportaudio -lfltk -lasound -llo -lsndfile -ldl -lm -lpthread
>> libcsnd.so.5.2
> 
> Removing that part, the problem is fixed:
> 
>> g++ -o _csnd.so -Wl,-Bdynamic -Wl,-rpath-link,. -shared 
>> interfaces/python_interface_wrap.os -L/usr/local/lib -L/usr/lib
>> -L/usr/lib/python2.6/config -L. -L. -L/usr/local/lib -L. -L.
>> -L/usr/lib/fltk-1.1 -lpython2.6 -llua -lstdc++ -lutil -lsndfile -lsndfile
>> -lpthread -lpthread -lm -lportaudio -lfltk -lasound -llo -lsndfile -ldl
>> -lm -lpthread libcsnd.so.5.2
> 
>> cp _csnd.so /usr/lib/python2.6/site-packages/
> 
>> python -c "import csnd"
> 
> OK
> 
> Do you think this fix could result in other problems? For now I've just
> modified SConstruct this way, at line 1115:
> 
> < tmp += ['-Wl,-soname=%s' % libName2]
>> # tmp += ['-Wl,-soname=%s' % libName2]
> 
> Please, tell me what do you think. I'm maintaining the archlinux csound5
> package and I don't want to introduce subtle bugs that I'm not aware of.
> 
> Best regards
> -Carlos
> 
> 
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/Dynamic-libcsound-breaks-python-binding-tp21266916p21267233.html
Sent from the Csound - Dev mailing list archive at Nabble.com.


------------------------------------------------------------------------------
_______________________________________________
Csound-devel mailing list
Csound-devel@lists.sourceforge.net

Date2009-01-04 21:05
FromFelipe Sateler
SubjectRe: [Cs-dev] Dynamic libcsound breaks python binding
AttachmentsNone  None  None  

Date2009-01-05 20:09
From"Andres Cabrera"
SubjectRe: [Cs-dev] Dynamic libcsound breaks python binding
AttachmentsNone  

Date2009-01-06 02:30
FromCarlosJP
SubjectRe: [Cs-dev] Dynamic libcsound breaks python binding
Buenas Felipe,

the patch as is doesn't fix the issue, but if you only change libcsnd for
libcsound it does.

Notice that the problematic part in the build line:

> > g++ -o _csnd.so -Wl,-Bdynamic -Wl,-rpath-link,. -shared
> > -Wl,-soname=libcsound.so.5.2 interfaces/python_interface_wrap.os
> > -L/usr/local/lib -L/usr/lib -L/usr/lib/python2.6/config -L. -L.
> > -L/usr/local/lib -L. -L. -L/usr/lib/fltk-1.1 -lpython2.6 -llua -lstdc++
> > -lutil -lsndfile libcsound.so.5.2 -lsndfile -lpthread -lpthread -lm
> > -lportaudio -lfltk -lasound -llo -lsndfile -ldl -lm -lpthread
> > libcsnd.so.5.2 

is  -Wl,-soname=libcsound.so.5.2.

Another thing that can be removed from this line is the linking of
libcsound.so. It's not really needed as it's already linked into libcsnd.so.

Sorry for the delayed answer, I was too busy these last two days.

Best regards
-Carlos


Felipe Sateler wrote:
> 
> Hmm, it seems I didn't commit the change fixing this. Try this patch, if
> it 
> works I'll commit it:
> 
> --- csound.orig/SConstruct      2008-12-22 16:30:06.000000000 -0300
> +++ csound/SConstruct   2008-12-22 16:37:33.000000000 -0300
> @@ -1368,6 +1368,9 @@
>          csoundInterfacesEnvironment.Append(CPPPATH = pythonIncludePath)
>          csndPythonEnvironment = csoundInterfacesEnvironment.Clone()
>          fixCFlagsForSwig(csndPythonEnvironment)
> +        flag = '-Wl,-soname=libcsnd.so.%s' % csoundLibraryVersion
> +        if flag in csndPythonEnvironment['SHLINKFLAGS']:
> +             csndPythonEnvironment['SHLINKFLAGS'].remove(flag)
>          if getPlatform() == 'darwin':
>              if commonEnvironment['dynamicCsoundLibrary'] == '1':
>                  csndPythonEnvironment.Append(LIBS = ['_csnd'])
> 
> 
> 
> El 03/01/09 14:09 CarlosJP escribió:
>> Hi all,
>>
>> when building with dynamicCsoundLibrary=1, python binding is unable to
>> resolve some symbols:
>>
>> [carlos@carlos tmp]$ python -c "import csnd"
>> Traceback (most recent call last):
>>   File "", line 1, in 
>>   File "/usr/lib/python2.6/site-packages/csnd.py", line 7, in 
>>     import _csnd
>> ImportError: /usr/lib/libcsnd.so.5.2: undefined symbol:
>> csoundInitTimerStruct
>>
>> I've tracked down the issue to find out that it's related to the use of
>>
>> soname=libcsound.so.5.2 while linking _csnd.so:
>> > g++ -o _csnd.so -Wl,-Bdynamic -Wl,-rpath-link,. -shared
>> > -Wl,-soname=libcsound.so.5.2 interfaces/python_interface_wrap.os
>> > -L/usr/local/lib -L/usr/lib -L/usr/lib/python2.6/config -L. -L.
>> > -L/usr/local/lib -L. -L. -L/usr/lib/fltk-1.1 -lpython2.6 -llua -lstdc++
>> > -lutil -lsndfile libcsound.so.5.2 -lsndfile -lpthread -lpthread -lm
>> > -lportaudio -lfltk -lasound -llo -lsndfile -ldl -lm -lpthread
>> > libcsnd.so.5.2
>>
>> Removing that part, the problem is fixed:
>> > g++ -o _csnd.so -Wl,-Bdynamic -Wl,-rpath-link,. -shared
>> > interfaces/python_interface_wrap.os -L/usr/local/lib -L/usr/lib
>> > -L/usr/lib/python2.6/config -L. -L. -L/usr/local/lib -L. -L.
>> > -L/usr/lib/fltk-1.1 -lpython2.6 -llua -lstdc++ -lutil -lsndfile
>> -lsndfile
>> > -lpthread -lpthread -lm -lportaudio -lfltk -lasound -llo -lsndfile -ldl
>> > -lm -lpthread libcsnd.so.5.2
>> >
>> > cp _csnd.so /usr/lib/python2.6/site-packages/
>> >
>> > python -c "import csnd"
>>
>> OK
>>
>> Do you think this fix could result in other problems? For now I've just
>> modified SConstruct this way, at line 1115:
>>
>> < tmp += ['-Wl,-soname=%s' % libName2]
>>
>> > # tmp += ['-Wl,-soname=%s' % libName2]
>>
>> Please, tell me what do you think. I'm maintaining the archlinux csound5
>> package and I don't want to introduce subtle bugs that I'm not aware of.
>>
>> Best regards
>> -Carlos
> 
> 
> 
> Saludos,
> Felipe Sateler
> 
>  
> ------------------------------------------------------------------------------
> 
> _______________________________________________
> Csound-devel mailing list
> Csound-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/csound-devel
> 
> 

-- 
View this message in context: http://www.nabble.com/Dynamic-libcsound-breaks-python-binding-tp21266916p21303594.html
Sent from the Csound - Dev mailing list archive at Nabble.com.


------------------------------------------------------------------------------
_______________________________________________
Csound-devel mailing list
Csound-devel@lists.sourceforge.net
https

Date2009-01-06 16:07
FromFelipe Sateler
SubjectRe: [Cs-dev] Dynamic libcsound breaks python binding
AttachmentsNone  None  None  

Date2009-01-06 19:25
From"Andres Cabrera"
SubjectRe: [Cs-dev] Dynamic libcsound breaks python binding
AttachmentsNone  

Date2009-01-06 21:11
FromFelipe Sateler
SubjectRe: [Cs-dev] Dynamic libcsound breaks python binding
AttachmentsNone  None  None