gcc and linking problems?

Rupert Wood me@rupey.net
Fri Sep 8 12:06:00 GMT 2006

Hugh Sasse wrote:

> fft_2d_filter.o: In function `fft_2d_forward':
> fft_2d_filter.c:(.text+0x28): undefined reference to
>    `fftw_plan_dft_r2c_2d'
> fft_2d_filter.c:(.text+0x3c): undefined reference to `fftw_execute'
> The first form (.text+0x<something>) I don't recall seeing before, 
> though I've been using gcc since about 1990, and these functions are
> defined in the headers.

That's the offset in object file section where it's encountering the error,
analogous to the line number GCC prints when you have a source error.

You need to check that it's looking for the right things and that they're
actually available. When you say 'defined in headers' what exactly do you
mean: that these are inline functions in your header file? Or that you
declare the prototypes in the header file but they're in one of the other
sources or one of the libraries, e.g. libfftw3? You should check that the
functions are available in the object file or library you think they're
coming from, e.g. by using nm. (If this was Windows I'd ask about calling
conventions but I don't think Solaris has any problems with that: however
you could make sure e.g. that the symbol names consistently do or don't have
a leading underscore.)

> The second one seems to be a linker problem, since it is complaining
> about the library file itself.  Other programs seem to be working
> with PNG images correctly, however.  

It's complaining that it can't find deflate, which is defined in libz. Link
order is significant: you must link libz *after* you link libpng since
libpng depends on it.

> LD = /usr/local/bin/ld

I realise this might be because you're playing with different ld versions
but it's generally a good idea to use gcc as LD too - the compiler driver
will run the linker for you. (Particularly when you're dealing with C++ and
templates, or when you're creating libraries, though, so it might not be
significant here.)

This email has been scanned by the MessageLabs Email Security System.
For more information please visit http://www.messagelabs.com/email 

More information about the Gcc-help mailing list