Re: using static libraries

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello there,

I advised you to put the library inclusions (eg. -lpthread) last in the command line, because the gnu linker satisfies the reference at these libraries after encountering the C files that call them.

In fact, as you can notice, the errors the linker now gives are related to the libraries, and not to your user code any longer. (while, before issuing the command as I suggested you, the build stopped even before, because it did not find the library requested to link).

The series of errors are probably due to the -static switch. Just check if your compilation succeeds without -static, and if yes, you probably should satisfy all the references libsndfile needs to get the final, totally linked, executable file, with the -static switch.

Let me know,

J.

--- On Sun, 11/28/10, Kristoff Bonne <kristoff.bonne@xxxxxxxxx> wrote:

> From: Kristoff Bonne <kristoff.bonne@xxxxxxxxx>
> Subject: Re: using static libraries
> To: gcc-help@xxxxxxxxxxx
> Date: Sunday, November 28, 2010, 8:00 PM
> Hi Josef,
> 
> 
> Op 28-11-10 01:38, Josef Ahmad schreef:
> > Hi Kristoff,
> > put "-lpthread -lsndfile -lrt" *after* "wav2ambe.c"
> 
> Well, that seams to make it even worse:
> 
> $ gcc -static -o wav2ambe wav2ambe.c -lsndfile 
> -lpthread -lrt
> /usr/lib/gcc/i486-linux-gnu/4.4.3/../../../../lib/libsndfile.a(caf.o):
> In function `caf_open':
> (.text+0xa56): undefined reference to `lrint'
> /usr/lib/gcc/i486-linux-gnu/4.4.3/../../../../lib/libsndfile.a(flac.o):
> In function `flac_write_d2flac':
> (...)
> 
> (411 lines of error-messages).
> 
> 
> 
> By the way:
> - I have tried this on three different versions of linux:
> Ubuntu 10.04 (gcc 4.4.3), CentOS 5.5 (gcc 4.1.2) and
> Debian/ppc (gcc 4.3.2): all the same result.
> 
> So this is not related to one particular version of gcc or
> linux.
> 
> 
> - The following also gives the same result:
> 
> $ gcc -o wav2ambe /usr/lib/libsndfile.a 
> /usr/lib/libpthread.a /usr/lib/librt.a wav2ambe.c
> 
> /tmp/cceYqhlc.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
> 
> 
> So it must really be something I do wrong.
> 
> Anybody any idea?
> 
> 
> 
> 
> > Greetings,
> > J.
> Cheerio! Kr. Bonne.
> 
> 






[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux