using static libraries

Kristoff Bonne kristoff.bonne@skypro.be
Sun Nov 28 00:38:00 GMT 2010


Hi,


I have a question about using static libraries and sofar I have not 
found it on the internet-archive.


I'm working on a software-package to create voice-announcement on D-STAR 
repeaters (radio-amateur digital voice repeaters).

I use three external libraries: libsndfile (read the wav-file), pthread 
(posix threads) and rt (for timed interrupts).


As the repeaters by default run a version of CentOS where "libsndfile" 
is not installed, nor present in the default repostitory, it needs to be 
installed from source.
So far, so good.

However, there are a number of people who also have other software 
running on these boxex, including asterisk, who also uses the 
libsndfile. (be it, only the run-time libraries, not the include-files).

So, to be sure not to create any confict with these programs and these 
versions of the libsndfile-library, I want to include binary versions of 
the programs in my package, using statically linking (read: no external 
libraries needed, so no change of conflict).


However, when I try to compile my programs using the "-static" option, 
it looks like the linker cannot reference to the external functions:

$ gcc -static -L /usr/lib/ -o wav2ambe -lpthread -lsndfile -lrt wav2ambe.c
/tmp/ccAUZGl5.o: In function `main':
wav2ambe.c:(.text+0x11ff): undefined reference to `sf_open'
wav2ambe.c:(.text+0x1593): undefined reference to `pthread_create'
wav2ambe.c:(.text+0x1666): undefined reference to `timer_create'
wav2ambe.c:(.text+0x16f8): undefined reference to `timer_settime'
wav2ambe.c:(.text+0x1782): undefined reference to `sf_read_short'
wav2ambe.c:(.text+0x18ff): undefined reference to `timer_settime'
collect2: ld returned 1 exit status

The strange thing is that, when I run "strace -f", I do see that the .a 
files (/usr/lib/libpthread.a, /usr/lib/libsndfile.a and 
/usr/lib/librt.a) are read!!!

So am I doing something wrong here?



The program-code can be found here:
http://villazeebries.krbonne.net/dstar/voice-announce/

The blog about the program is here:
http://villazeebries.krbonne.net/hamstuff/


Any info greatly appriciated!

Cheerio!
Kr. Bonne



More information about the Gcc-help mailing list