arm-none-eabi-gcc report a error and ld can not work.

Asked by zhanggang

when I use the arm-none-eabi-gcc(4.8.3) to compile the hello word c program( arm-none-eabi-gcc hello.c -o hello), there are some error:
/home/zg/Baremetaltools/gcc-arm-none-eabi-4_8-2014q1/bin/../lib/gcc/arm-none-eabi/4.8.3/../../../../arm-none-eabi/lib/libc.a(lib_a-exit.o): In function `exit':
exit.c:(.text.exit+0x2c): undefined reference to `_exit'
/home/zg/Baremetaltools/gcc-arm-none-eabi-4_8-2014q1/bin/../lib/gcc/arm-none-eabi/4.8.3/../../../../arm-none-eabi/lib/libc.a(lib_a-sbrkr.o): In function `_sbrk_r':
sbrkr.c:(.text._sbrk_r+0x18): undefined reference to `_sbrk'
/home/zg/Baremetaltools/gcc-arm-none-eabi-4_8-2014q1/bin/../lib/gcc/arm-none-eabi/4.8.3/../../../../arm-none-eabi/lib/libc.a(lib_a-writer.o): In function `_write_r':
writer.c:(.text._write_r+0x20): undefined reference to `_write'
/home/zg/Baremetaltools/gcc-arm-none-eabi-4_8-2014q1/bin/../lib/gcc/arm-none-eabi/4.8.3/../../../../arm-none-eabi/lib/libc.a(lib_a-closer.o): In function `_close_r':
closer.c:(.text._close_r+0x18): undefined reference to `_close'
/home/zg/Baremetaltools/gcc-arm-none-eabi-4_8-2014q1/bin/../lib/gcc/arm-none-eabi/4.8.3/../../../../arm-none-eabi/lib/libc.a(lib_a-fstatr.o): In function `_fstat_r':
fstatr.c:(.text._fstat_r+0x1c): undefined reference to `_fstat'
/home/zg/Baremetaltools/gcc-arm-none-eabi-4_8-2014q1/bin/../lib/gcc/arm-none-eabi/4.8.3/../../../../arm-none-eabi/lib/libc.a(lib_a-isattyr.o): In function `_isatty_r':
isattyr.c:(.text._isatty_r+0x18): undefined reference to `_isatty'
/home/zg/Baremetaltools/gcc-arm-none-eabi-4_8-2014q1/bin/../lib/gcc/arm-none-eabi/4.8.3/../../../../arm-none-eabi/lib/libc.a(lib_a-lseekr.o): In function `_lseek_r':
lseekr.c:(.text._lseek_r+0x20): undefined reference to `_lseek'
/home/zg/Baremetaltools/gcc-arm-none-eabi-4_8-2014q1/bin/../lib/gcc/arm-none-eabi/4.8.3/../../../../arm-none-eabi/lib/libc.a(lib_a-readr.o): In function `_read_r':
readr.c:(.text._read_r+0x20): undefined reference to `_read'
collect2: error: ld returned 1 exit status

why? I download the tool from launchpad.net, but I do not find the reason why the tool can not work? please help me! thanks!

Question information

Language:
English Edit question
Status:
Solved
For:
GNU Arm Embedded Toolchain Edit question
Assignee:
No assignee Edit question
Solved by:
Joey Ye
Solved:
Last query:
Last reply:
Revision history for this message
Best Joey Ye (jinyun-ye) said :
#1

Pls add -specs=nosys.specs to your linker option.
2014-6-4 下午8:21于 "zhanggang" <email address hidden>写道:

> New question #249756 on GCC ARM Embedded:
> https://answers.launchpad.net/gcc-arm-embedded/+question/249756
>
> when I use the arm-none-eabi-gcc(4.8.3) to compile the hello word c
> program( arm-none-eabi-gcc hello.c -o hello), there are some error:
> /home/zg/Baremetaltools/gcc-arm-none-eabi-4_8-2014q1/bin/../lib/gcc/arm-none-eabi/4.8.3/../../../../arm-none-eabi/lib/libc.a(lib_a-exit.o):
> In function `exit':
> exit.c:(.text.exit+0x2c): undefined reference to `_exit'
> /home/zg/Baremetaltools/gcc-arm-none-eabi-4_8-2014q1/bin/../lib/gcc/arm-none-eabi/4.8.3/../../../../arm-none-eabi/lib/libc.a(lib_a-sbrkr.o):
> In function `_sbrk_r':
> sbrkr.c:(.text._sbrk_r+0x18): undefined reference to `_sbrk'
> /home/zg/Baremetaltools/gcc-arm-none-eabi-4_8-2014q1/bin/../lib/gcc/arm-none-eabi/4.8.3/../../../../arm-none-eabi/lib/libc.a(lib_a-writer.o):
> In function `_write_r':
> writer.c:(.text._write_r+0x20): undefined reference to `_write'
> /home/zg/Baremetaltools/gcc-arm-none-eabi-4_8-2014q1/bin/../lib/gcc/arm-none-eabi/4.8.3/../../../../arm-none-eabi/lib/libc.a(lib_a-closer.o):
> In function `_close_r':
> closer.c:(.text._close_r+0x18): undefined reference to `_close'
> /home/zg/Baremetaltools/gcc-arm-none-eabi-4_8-2014q1/bin/../lib/gcc/arm-none-eabi/4.8.3/../../../../arm-none-eabi/lib/libc.a(lib_a-fstatr.o):
> In function `_fstat_r':
> fstatr.c:(.text._fstat_r+0x1c): undefined reference to `_fstat'
> /home/zg/Baremetaltools/gcc-arm-none-eabi-4_8-2014q1/bin/../lib/gcc/arm-none-eabi/4.8.3/../../../../arm-none-eabi/lib/libc.a(lib_a-isattyr.o):
> In function `_isatty_r':
> isattyr.c:(.text._isatty_r+0x18): undefined reference to `_isatty'
> /home/zg/Baremetaltools/gcc-arm-none-eabi-4_8-2014q1/bin/../lib/gcc/arm-none-eabi/4.8.3/../../../../arm-none-eabi/lib/libc.a(lib_a-lseekr.o):
> In function `_lseek_r':
> lseekr.c:(.text._lseek_r+0x20): undefined reference to `_lseek'
> /home/zg/Baremetaltools/gcc-arm-none-eabi-4_8-2014q1/bin/../lib/gcc/arm-none-eabi/4.8.3/../../../../arm-none-eabi/lib/libc.a(lib_a-readr.o):
> In function `_read_r':
> readr.c:(.text._read_r+0x20): undefined reference to `_read'
> collect2: error: ld returned 1 exit status
>
> why? I download the tool from launchpad.net, but I do not find the
> reason why the tool can not work? please help me! thanks!
>
> --
> You received this question notification because you are an answer
> contact for GCC ARM Embedded.
>

Revision history for this message
zhanggang (zhanggang) said :
#2

Thank your answer. Now all do work!
 I want to know whether there are some documentions which introduce me how to use the "--specs" parameter. I do not have any information about the --specs=nosys.specs parameter. If have,please tell me. Thanks!

Revision history for this message
zhanggang (zhanggang) said :
#3

Thanks Joey Ye, that solved my question.

Revision history for this message
zhanggang (zhanggang) said :
#4

Hi Joey,

 I now want to build a bare metal c++ porject on the ARM Cortex-A8 soc. The C++ project need the NEON and hard float unit. so I want to use the arm-none-eabi-* tool sets to build the project. The arm-none-eabi-* tool can meet my requirment?
Thank you!

Revision history for this message
Joey Ye (jinyun-ye) said :
#5

All descriptions can be found in readme.txt.

Yes. It has the functionality to build bare-metal project for Cortex-A too,
although not with the latest best performance.

On Thu, Jun 5, 2014 at 11:31 AM, zhanggang <
<email address hidden>> wrote:

> Question #249756 on GCC ARM Embedded changed:
> https://answers.launchpad.net/gcc-arm-embedded/+question/249756
>
> zhanggang posted a new comment:
> Hi Joey,
>
> I now want to build a bare metal c++ porject on the ARM Cortex-A8 soc.
> The C++ project need the NEON and hard float unit. so I want to use the
> arm-none-eabi-* tool sets to build the project. The arm-none-eabi-* tool
> can meet my requirment?
> Thank you!
>
> --
> You received this question notification because you are an answer
> contact for GCC ARM Embedded.
>

Revision history for this message
zhanggang (zhanggang) said :
#6

thank your answer!
I also study some documention including the readme and know about the --specs.
"although not with the latest best performance" , It means that the tool sets have the best performance for the Cortex-M/R and not have the best performance for Cortex-A. The tool sets do more optimizing for the Cortex-M/R than the Cortex-A. Is it correct?

Revision history for this message
zhanggang (zhanggang) said :
#7

Another question: The arm-none-eabi* tool sets only support Thum instruction set , not support ARM instruction set? Is it right?

Revision history for this message
Thomas Preud'homme (thomas-preudhomme) said :
#8

Hi Zhanggang,

The toolchain supports both Thumb mode and ARM mode. Just try compiling with -mcpu=cortex-a9 -marm for instance. Obviously this will not work for a CPU that doesn't have ARM mode such as the cortex-m3 that is the default cpu of this toolchain. If that is the case, you will then see a message like this:

"error: target CPU does not support ARM mode."

Revision history for this message
zhanggang (zhanggang) said :
#9

I see! Thank you very much! I will use the tool set to compille my c++ bare metal project on Cortex-A8 soc.