Simple linking problem
Andrew Haley
aph-gcc@littlepinkcloud.COM
Thu May 10 11:42:00 GMT 2007
gccNewbie writes:
>
>
> Andrew Haley-5 wrote:
> >
> > Yes. The command is called "nm".
> >
>
> Thanks. It seems to often happen that what you are looking for is in the
> last place you look. Usually you ask for help online just before looking in
> that last place, too. I discovered nm mere minutes after asking my question.
>
> Unfortunately, nm merely confirmed what I already knew. It has some rather
> complicated output, but the names of these so-called undefined functions are
> in the library, right next to a T which should mean that the library
> provides a definition of these functions.
>
> So it is really a very simple riddle. 'gcc -lmylib mysource.c' uses a
> function 'foo' which nm shows is defined in libmylib.a. gcc does not
> complain about not being able to find mylib, but it does complain that 'foo'
> is an 'undefined reference'. In what situation could that happen?
Maybe link ordering, maybe link paths.
if it's link ordering, 'gcc -lmylib mysource.c -lmylib' will fix it.
If it's link paths, you need '-L.'
If neither of those work, we need to start debugging.
Andrew.
More information about the Gcc-help
mailing list