This is the mail archive of the
newlib@sources.redhat.com
mailing list for the newlib project.
Re: How to use newlib(mips)
- To: Li Chengyuan <chengyuanli at hotmail dot com>
- Subject: Re: How to use newlib(mips)
- From: "J. Johnston" <jjohnstn at cygnus dot com>
- Date: Tue, 10 Jul 2001 16:53:22 -0400
- CC: i dot krabbe at dokom dot net, newlib at sources dot redhat dot com
- Organization: Red Hat Inc.
- References: <F116jCRGryWtIIZS2TR0000c30d@hotmail.com>
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.