LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 02-09-2009, 07:25 PM   #1
MrUmunhum
Member
 
Registered: May 2006
Location: Mt Umunhum, CA, USA, Earth
Distribution: Debian/ Fedora/ Ubuntu/ Raspbian
Posts: 549

Rep: Reputation: 40
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??
 
Old 02-11-2009, 05:45 AM   #2
rylan76
Senior Member
 
Registered: Apr 2004
Location: Potchefstroom, South Africa
Distribution: Fedora 17 - 3.3.4-5.fc17.x86_64
Posts: 1,552

Rep: Reputation: 103Reputation: 103
Are you sure you have a file called

Code:
libasound.a
on your system?

If you do, is it in your PATH?
 
Old 02-12-2009, 01:40 PM   #3
MrUmunhum
Member
 
Registered: May 2006
Location: Mt Umunhum, CA, USA, Earth
Distribution: Debian/ Fedora/ Ubuntu/ Raspbian
Posts: 549

Original Poster
Rep: Reputation: 40
fixed that problem but found more

Quote:
Originally Posted by rylan76 View Post
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.
 
Old 02-13-2009, 07:39 AM   #4
rylan76
Senior Member
 
Registered: Apr 2004
Location: Potchefstroom, South Africa
Distribution: Fedora 17 - 3.3.4-5.fc17.x86_64
Posts: 1,552

Rep: Reputation: 103Reputation: 103
[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...
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
ld static link failed ???? SkinnerC Ubuntu 2 11-27-2008 02:03 PM
problem when trying to static link with gcc glvgfz Programming 11 09-18-2005 07:58 PM
how to static link a specific library? koodailar Programming 3 07-26-2004 03:35 PM
Alsa STATIC Falieson Linux - Software 3 04-12-2004 12:07 AM
Static with ALSA Berto Linux - General 0 12-27-2003 04:11 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

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

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration