question about library?

J. Johnston
Mon Mar 3 23:29:00 GMT 2003

Could you elaborate on how you tried to compile/link your program?

The reference to _exit is expected.  This should be supplied by libgloss.
Now, I do not know if you are building for the sim or for a target board.
There are multiple libraries supplied by libgloss.  For example, you can
link in the sim library using -lsim.  You would see similar errors
for the I/O routines which require _read, _write, among other syscalls which are
again supplied by libgloss.

The __errno reference is due to the fact that libm has references to
libc's errno.  When you link, your list of libraries is order-dependent.
The archives are searched one by one to resolve all current unresolved
references.  Once the linker moves to the next archive, it does not back-up.
So, if you have -la -lb specified and your "a" library requires something from
your "b" library which subsequently requires something from your "a" library,
it will not go back and search liba.a again.  In the case of errno, it usually
is already linked in if you put -lc in front of -lm.  You can tell the linker you
want to iterate through the library list by using the gcc --start-group
and --end-group options.  If you put these around the libraries you are linking,
this will handle interdependencies between the libraries.  You can also
specify this via an ld script which uses the GROUP specifier.  For example,
look at the pe-cmb.ld script in libgloss/mcore.

-- Jeff J.

top_general wrote:
> I used newlib-1.10.0 to compile a library for Motorola M.Core2107 mcu. I had compiled successly. when I debugged these functions, I found many functions not to used. Question is follow(for example): 
> 1. /cygdrive/e/cygwin/usr/local/mcore/mcore-elf/lib/big/libg.a(exit.o): 
> In function `exit': 
> exit.o(.text+0x48): undefined reference to `_exit' 
> 2. /cygdrive/e/cygwin/usr/local/mcore/mcore-elf/lib/big/libm.a(w_asin.o): 
> In function `asin': 
> w_asin.o(.text+0xb0): undefined reference to `__errno' 
> 3. IO functions can't to use. For example: 
> ¡¡ printf, scanf...... 
> fopen,fclose.... 
> 4. These functions can't also to use. Include: 
> malloc,calloc,realloc,free. 
> How can I compile new library for M.CORE2107? Do I need to amend source codes? Please give me some advices and method. thanks...
> ______________________________________
> ===================================================================
> ÊÖ»úÓïÒôÁÄÌì¹úÄÚ³¤Í¾5·ÖÖÓ/1Ôª¡¢Ë§¸çÃÀÃ
®ö¦ÕÕ¾¡ÔÚ°®Çé¿ìµÝ (
> ÊÖ»ú¶ÌÐÃ
·¢ËÍmµ½888810£¬Ãâ·Ñ»ñµÃÐÂÀË15MÈÎÄãÓÊÓÊÏ䣡 (
> çÍ·×ÏÂÔؾãÀÖ²¿ ÿÔÂ5ԪͼƬÁåÉùËæÐÄ»» (

More information about the Newlib mailing list