automake
[Top][All Lists]
Advanced

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

Re: Getting 'undefined reference' errors during linking but I think I in


From: cs
Subject: Re: Getting 'undefined reference' errors during linking but I think I included all libraries?!?
Date: Thu, 1 May 2003 21:41:28 -0700 (MST)

Rusty

Thanks for the help.  I was tweaking Makefile.am's to see
if I could get one that worked and made some progress.
I learned something I will tell you that I hope you knew.

This is one of those things that could make you scream
if you were a victim to it.....

Did you know that when you link all the stuff to make
the executable that the *order matters*?!?!?

e.g.

gcc -o myprogram myprogram.o func1.o func2.o
      -L $(srcdir)/libs -lsomearchive -lm -lX11
       -lpthread -L somepath ...etc.

The -L guys *must* be *after* the object files!!!!
The whole reason for my problem was that I put the
-L stuff in my name_LDFLAGS line instead of
name_LDADD!!!

Automake apparently puts name_LDFLAGS stuff *before* .o files and
name_LDADD stuff *after* when linking!!!!

Not only that but if some libraries depend on other ones
then you must be careful of the /order/ you specify all the -l guys in!!!

I kept modifying the gcc link line and finally got one
that WORKED!!! The trick now is getting Makefile.am to reflect
that.

In a nutshell, all my components were fine but it was
*just* the _order_ of all the junk that caused the
"undefined reference" errors!!!!

Can you believe it!?

Chris




_______________________________________

Dr. Christian Seberino
Gnumatica Scientific Software
8665 Lake Murray Blvd. #3
San Diego, CA 92119-2843
U.S.A.

Phone: (619) 393-9047
Email: address@hidden
WWW  : www.gnumatica.com
_______________________________________

 -------- Original Message --------
   Subject: Re: Getting "undefined reference" errors during linking but I
think I included all libraries?!?
   From: "Rusty Ballinger" <address@hidden>
   Date: Thu, May 1, 2003 1:58 pm
   To: address@hidden

   > I would appreciate any help finding reason for getting
   > "undefined reference" errors during very last step
   > of build process --- the linking to make executable.
   > This seems to me to mean I'm not linking a necessary library.
   > However, I have stared at the output and I can see
   > all the -L's and -l's that should be there.

   One question is what the undefined symbols are.  If you recognize them
   as stuff you wrote, or as part of the thing you're building, then that
   probably means your link line is missing one of the .o's.  With
   automake this most likely means you left a source file out of
   foo_SOURCES?

   If you think the symbols really are coming from a missing library, and
   you think you have the library installed (as you probably do if you
   have the headers corresponding to the library, which you probably
   would've needed in order to compile .o's with references to those
   symbols), then (if you don't have any better ideas) you can do
   something horrible like nm -o /usr/lib/lib* | fgrep
   one_of_those_symbols to try to figure out which library the missing
   symbols are coming from.  But most likely the symbol names should give
   you a hint.  And there's probably an easier way to do that anyway, ha
   ha.

   --Rusty







reply via email to

[Prev in Thread] Current Thread [Next in Thread]