LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   ALSA, link static, cannot find -lasound (https://www.linuxquestions.org/questions/linux-software-2/alsa-link-static-cannot-find-lasound-703473/)

MrUmunhum 02-09-2009 07:25 PM

ALSA, link static, cannot find -lasound
 
hi group,

Trying to rebuild my ALSA programs with static libs.

Code:

Here is what works:
$ gcc  -g -O2  -lasound -o volume volume.o
$ file volume
volume: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.9, not stripped

but when I try with -static, I get this:
Code:

gcc  -g -O2 -static  -lasound -o volume volume.o
/usr/local/lib/gcc/i686-pc-linux-gnu/4.3.2/../../../../i686-pc-linux-gnu/bin/ld: cannot find -lasound

Any ideas??

rylan76 02-11-2009 05:45 AM

Are you sure you have a file called

Code:

libasound.a
on your system?

If you do, is it in your PATH?

MrUmunhum 02-12-2009 01:40 PM

fixed that problem but found more
 
Quote:

Originally Posted by rylan76 (Post 3439471)
Are you sure you have a file called

Code:

libasound.a
on your system?

If you do, is it in your PATH?

I nade the static libraries for ALSA but then found more problems.
Had to add lpthread and -ldl. That caused a warning that I could not clear up.
Code:

gcc  -g -O2 -static -lasound -lpthread -ldl  -o vmsrec vmsrec.o args.o file.o help.o audio.o S-2-A.o console.o comport.o 
vmsrec.o: In function `Quit':
/src/VMS/v1.1/src/record/vmsrec.c:293: undefined reference to `snd_pcm_drop'
/src/VMS/v1.1/src/record/vmsrec.c:294: undefined reference to `snd_pcm_close'
vmsrec.o: In function `main':
/src/VMS/v1.1/src/record/vmsrec.c:165: undefined reference to `snd_pcm_readi'
audio.o: In function `Close_Audio':
/src/VMS/v1.1/src/record/audio.c:87: undefined reference to `snd_pcm_close'
audio.o: In function `Open_Audio':
/src/VMS/v1.1/src/record/audio.c:21: undefined reference to `snd_pcm_open'
/src/VMS/v1.1/src/record/audio.c:26: undefined reference to `snd_pcm_poll_descriptors_count'
/src/VMS/v1.1/src/record/audio.c:34: undefined reference to `snd_pcm_poll_descriptors'
/src/VMS/v1.1/src/record/audio.c:42: undefined reference to `snd_pcm_hw_params_sizeof'
/src/VMS/v1.1/src/record/audio.c:42: undefined reference to `snd_pcm_hw_params_sizeof'
/src/VMS/v1.1/src/record/audio.c:43: undefined reference to `snd_pcm_hw_params_any'
/src/VMS/v1.1/src/record/audio.c:45: undefined reference to `snd_pcm_hw_params_set_access'
/src/VMS/v1.1/src/record/audio.c:46: undefined reference to `snd_pcm_hw_params_set_channels'
/src/VMS/v1.1/src/record/audio.c:47: undefined reference to `snd_pcm_hw_params_set_format'
/src/VMS/v1.1/src/record/audio.c:48: undefined reference to `snd_pcm_hw_params_set_rate_near'
/src/VMS/v1.1/src/record/audio.c:50: undefined reference to `snd_pcm_hw_params'
/src/VMS/v1.1/src/record/audio.c:53: undefined reference to `snd_pcm_start'
collect2: ld returned 1 exit status
make: *** [vmsrec] Error 1


$ sudo locate libasound.a
/src/ALSA/alsa-lib-1.0.9rc4/src/.libs/libasound.a
/usr/lib/libasound.a

And to answer your question, I'm running FC8 with alsa-lib-1.0.9rc4.

rylan76 02-13-2009 07:39 AM

[QUOTE=MrUmunhum;3441347]I nade the static libraries for ALSA but then found more problems.
Had to add lpthread and -ldl. That caused a warning that I could not clear up.
Code:

gcc  -g -O2 -static -lasound -lpthread -ldl  -o vmsrec vmsrec.o args.o file.o help.o audio.o S-2-A.o console.o comport.o 
vmsrec.o: In function `Quit':
/src/VMS/v1.1/src/record/vmsrec.c:293: undefined reference to `snd_pcm_drop'
/src/VMS/v1.1/src/record/vmsrec.c:294: undefined reference to `snd_pcm_close'
vmsrec.o: In function `main':
/src/VMS/v1.1/src/record/vmsrec.c:165: undefined reference to `snd_pcm_readi'
audio.o: In function `Close_Audio':
/src/VMS/v1.1/src/record/audio.c:87: undefined reference to `snd_pcm_close'
audio.o: In function `Open_Audio':
/src/VMS/v1.1/src/record/audio.c:21: undefined reference to `snd_pcm_open'
/src/VMS/v1.1/src/record/audio.c:26: undefined reference to `snd_pcm_poll_descriptors_count'
/src/VMS/v1.1/src/record/audio.c:34: undefined reference to `snd_pcm_poll_descriptors'
/src/VMS/v1.1/src/record/audio.c:42: undefined reference to `snd_pcm_hw_params_sizeof'
/src/VMS/v1.1/src/record/audio.c:42: undefined reference to `snd_pcm_hw_params_sizeof'
/src/VMS/v1.1/src/record/audio.c:43: undefined reference to `snd_pcm_hw_params_any'
/src/VMS/v1.1/src/record/audio.c:45: undefined reference to `snd_pcm_hw_params_set_access'
/src/VMS/v1.1/src/record/audio.c:46: undefined reference to `snd_pcm_hw_params_set_channels'
/src/VMS/v1.1/src/record/audio.c:47: undefined reference to `snd_pcm_hw_params_set_format'
/src/VMS/v1.1/src/record/audio.c:48: undefined reference to `snd_pcm_hw_params_set_rate_near'
/src/VMS/v1.1/src/record/audio.c:50: undefined reference to `snd_pcm_hw_params'
/src/VMS/v1.1/src/record/audio.c:53: undefined reference to `snd_pcm_start'
collect2: ld returned 1 exit status
make: *** [vmsrec] Error 1

Yikes, not sure what is going on there... what this means (at least, some more knowledgable guys said so when I got the same types of errors) is that "you have an older or incompatible library version".

I. e. the vmsrec.c and audo.c files, refer to symbols that are not present in the libraries you have listed when you try to compile the program (from there the complaints about "undefined references".

I don't see how adding -lpthread -ldl (whatever "dl" is) can cause these.... Most likely you'll need to get a newer ALSA lib, if one exits, and try compiling against that?

Hope this helped...


All times are GMT -5. The time now is 11:14 AM.