[alsa-devel] ALSA calls don't work from a shared library

Olivier Guillion - Myriad olivier at myriad-online.com
Wed Aug 24 16:55:23 CEST 2011


Jaroslav Kysela wrote :
> It looks like a linking (linker) issue. Are you sure that your dynamic
> module is linked with libasound (-lasound option for gcc)?
> The command "ldd <your_so_file>" should print libasound.so in list.

Thank you very much for your answer!
I agree, it's definitely a link problem. 

If my main module sends the addresses of the ALSA functions to the shared 
library, the test works.
It then means that the shared library by itself doesn't know the right location 
of the functions, and that there is a problem during the run-time link.

It has then nothing to do with ALSA, but in my way of managing libraries. :)
I have 15 years of experience in C, but only a couple of months on Linux, and 
sometimes I'm a bit lost.

To make ALSA work in my projects (I'm using Code:Blocks), I added to the link 
section all the .so libraries I found in /usr/lib/alsa-lib. Apparently it 
worked for stand-alone programs, but not for shared libraries.

Could you please tell me what I should add to my project (I'm using 
Code:Blocks) to make my programs use the current ALSA shared library in the 
system? I tried to build the static lib (./configure --enable-makeshared=no --
enable-static=yes) then the shared lib (./configure --enable-makeshared=no --
enable-static=yes) but it seems to have corrupted my system. My already 
compiled old programs don't work anymore, saying that 
"snd_async_add_pcm_handler" is not implemented.

Sorry if my request is out of the topic of this mailing-list. Please do not 
hesitate to tell me if so.


More information about the Alsa-devel mailing list