How to use newlib(mips)
J. Johnston
jjohnstn@cygnus.com
Tue Jul 10 13:53:00 GMT 2001
Li Chengyuan wrote:
>
> hi,
> I have built the newlib in the directory /usr/local/mips-mips-elf/lib
> but when i want to link a program(The "Hello World") with the newlib,I
> met a problem.
> if I do:
> mips-mips-elf-gcc -o hello hello.c
> the error message is :
> /usr/local/mips-mips-elf/lib/crt0.o: In function `zerobss':
> ../../../../../gcc-2.95.3/libgloss/mips/crt0.S:132: undefined reference to
> `get_mem_info'
> ../../../../../gcc-2.95.3/libgloss/mips/crt0.S:136: undefined reference to
> `__stack'
> ../../../../../gcc-2.95.3/libgloss/mips/crt0.S:136: undefined reference to
> `__stack'
> /usr/local/mips-mips-elf/lib/crt0.o: In function `init':
> ../../../../../gcc-2.95.3/libgloss/mips/crt0.S:172: undefined reference to
> `hardware_init_hook'
> ../../../../../gcc-2.95.3/libgloss/mips/crt0.S:172: undefined reference to
> `hardware_init_hook'
> ../../../../../gcc-2.95.3/libgloss/mips/crt0.S:178: undefined reference to
> `software_init_hook'
> ../../../../../gcc-2.95.3/libgloss/mips/crt0.S:178: undefined reference to
> `software_init_hook'
> ../../../../../gcc-2.95.3/libgloss/mips/crt0.S:185: undefined reference to
> `atexit'
> /tmp/ccfZmRZZ.o: In function `main':
> hello.c(.text+0x18): undefined reference to `printf'
> /usr/local/lib/gcc-lib/mips-mips-elf/2.95.3/libgcc.a(_exit.o): In function
> `exit':
> /home/lcy/src/build/gcc/gcc/../../../gcc-2.95.3/gcc/libgcc2.c(.text+0x14):
> undefined reference to `_cleanup'
> collect2: ld returned 1 exit status
>
Li,
If you look in the libgloss/mips directory, you will find an assortment of ld scripts that contain
definitions for the missing symbols you are having problems with. Choose the ld script that is most
appropriate for your situation. If none of them are right, you can always write your own script
based on one that is close to what you need.
Once you have found or written the appropriate script, specify it using the -T compile option. For
example,
mips-mips-elf-gcc -Tidt.ld -o hello hello.c
-- Jeff J.
More information about the Newlib
mailing list