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

Re: gcc docs and linking...



On Tue, Jan 30, 2007 at 07:18:07PM +0000, Digby Tarvin wrote:
> Just when I thought I just about had a Debian system that
> was complete enough to develop on without needing access
> to my older distros....
> 
> Does anyone know how to fix:
> 	digbyt@fujitsu:~/work/audio$ man gcc
> 	No manual entry for gcc
> I have tried installing the gcc-4.1-doc package, but it didn't
> seem to help. I know man pages for gcc do exist, as all my other
> (non-Debian) systems seem to have them installed out of the box..
> 
> This is a Debian Etch system on a Fujitsu notebook.
> 
> The immediate issue that led me to attempt to consult the man
> page (in case someone can point out where I am going wrong)
> was a problem statically linking the oggfile libraries.
> 
>   cc -lvorbis -lvorbisfile -static -o oggplay oggplay.o
>   oggplay.o: In function `main':
>   oggplay.c:(.text+0xe7): undefined reference to `ov_open'
>   oggplay.c:(.text+0x2b6): undefined reference to `ov_info'
>   oggplay.c:(.text+0x473): undefined reference to `ov_read'
>   oggplay.c:(.text+0x48e): undefined reference to `ov_clear'
>   collect2: ld returned 1 exit status
>   make: *** [oggplay] Error 1
> 
> If I leave out the '-static' argument then the compile completes
> successfully (but using the shared version of the libs).
> 
> As far as I can see, the static library exists and defines the
> missing symbols, for example:
>   digbyt@fujitsu:~/work/audio$ nm /usr/lib/libvorbisfile.a | grep ov_open
>   000036e0 T ov_open
>   00003470 t _ov_open1
>   00002f90 t _ov_open2
>   00003690 T ov_open_callbacks
>   digbyt@fujitsu:~/work/audio$ nm /usr/lib/libvorbisfile.a | grep ov_info
>   000003e0 T ov_info
> 
> Anyone see where I am going wrong there?

Just to answer my own question here, it appears that static linking is
more fussy about the order of arguments, and also needs to have more
libraries specified on the command line (to resolve references made by
the linked in libraries...

In my case, the following command line worked:
 cc oggplay.o -lvorbisfile -lvorbis -logg -lm -static -o oggplay

Regards,
DigbyT
-- 
Digby R. S. Tarvin                                          digbyt(at)digbyt.com
http://www.digbyt.com



Reply to: