undefined reference to `printf' or puts under arm-none-eabi-gcc-6.2.1

Asked by shengyang on 2017-12-31

I want to build my projetc with stm32F7 code under linux use arm-none-eabi tools.Now i can build simpile project with led under Linux and success.But when i test usart mode,and use printf function with stdio.h head file.My source printf("yyfish nihao zhonguo") is just simple.
I get the err about yyfish.c:(.text.startup+0x38): undefined reference to `printf'.I try to define int __io_putchar(int ch) or int _write (int fd, const void *buf, size_t count),then i get the same error .But when I change this code as printf("yyfish nihao zhonguo\r\n");I get error as below
yyfish.c:(.text.startup+0x66): undefined reference to `puts'
and I add LDFLAGS=-L /usr/local/arm/gcc-arm-none-eabi-6_2-2016q4/arm-none-eabi/lib/thumb/v7e-m -l c -L /usr/local/arm/gcc-arm-none-eabi-6_2-2016q4/lib/gcc/arm-none-eabi/6.2.1/thumb/v7e-m -l gcc
but it's useless,what‘s wrong maybe???

Question information

Language:
English Edit question
Status:
Answered
For:
GNU ARM Embedded Toolchain Edit question
Assignee:
No assignee Edit question
Last query:
2017-12-31
Last reply:
2018-01-02
Tejas Belagod (belagod-tejas) said : #1

Hi,

You dont need to explicitly add the libs paths to the LD cmdline... the compiler driver knows where to pick the multilibs from depending on the options given.

Can you try:

$ arm-none-eabi-gcc -mcpu=cortex-m7 -mfloat-abi=hard -mfpu=fpv5-d16 -specs=rdimon.specs yyfish.c -o yyfish.out

and see if that cmd line works for you?

Thanks,
Tejas.

Can you help with this problem?

Provide an answer of your own, or ask shengyang for more information if necessary.

To post a message you must log in.