This is the mail archive of the crossgcc@sources.redhat.com mailing list for the crossgcc project.

See the CrossGCC FAQ for lots more infromation.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Library and linker errors


Russ.Shaw writes:
 > However, i get lots of linker errors like:
 > 
 > /usr/local/h8300-hms/lib/libg.a(strtol.o)(.text+0xfa):strtol.c:
 >                                  undefined reference to '__umodsi3'
 > /usr/local/h8300-hms/lib/libg.a(strtol.o)(.text+0x10a):strtol.c:
 >                                  undefined reference to '__udivsi3'
 > /usr/local/h8300-hms/lib/libg.a(strtol.o)(.text+0x152):strtol.c:
 >                                  undefined reference to '__umulsi3'
 > 
 > I can't find where __umodsi3 etc are defined. In my makefile, i'm
 > linking ld using -lgcc -liberty -lg -lc -lm.

Put -lgcc at the _end_, as in -liberty -lg -lc -lm -lgcc.

Remember that libraries are used to resolve undefined symbols
where they appear on the command line.  If a later library
depends on the symbols of an earlier library, you will not get them,
and that is what you are seeing here (-lg needs something in -lgcc,
but -lgcc appears too soon on the command line).

Actually, even that may not be sufficient (depending on the target).
GCC, when it does the link, puts -lgcc -lc -lgcc at the end.
This catches the case where libgcc references something in libc.

Why use ld to link at all?  Why not use gcc?
[One case where people get into particular trouble is if
they're using multilib'd libraries.  That can happen for the h8/300h,
I think (it's been awhile).  It may be the case that the default is
the h8/300, and you compile with -mh.  If that's the case then you
do NOT want the libraries in /usr/local/h8300-hms/lib, but rather
the ones in /usr/local/h8300-hms/lib/h8300h [or some such].
Ergo ---> just use gcc to link and let it worry about it.

[Of course, I could be all wet here with regards to your particular
situation.  Question:  Does /usr/local/h8300-hms/lib/h8300h exist
on your system?]

------
Want more information?  See the CrossGCC FAQ, http://www.objsw.com/CrossGCC/
Want to unsubscribe? Send a note to crossgcc-unsubscribe@sourceware.cygnus.com


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]