cancel
Showing results for 
Search instead for 
Did you mean: 

u_printf_float - where to set for C_Linker in STM32CubeIDE?

MFend
Associate III

When I compile, I get the following error:

The float formatting support (-u_printf_float)is not enabled from linker flags

I can't find Linker flags/Options/Settings for C - just for MCU G++ Linker. When I chose the option, it still didn't remove the error. It compiles, though and can be run.

0690X000009Xcm0QAC.jpg

1 ACCEPTED SOLUTION

Accepted Solutions
Yuk117
Associate III

This problem is fixed in STM32CubeIDE ver.1.0.2.

Workaround in older version is to add "-u _printf_float" to MCU GCC Linker -> Miscellaneous -> Other flags.

0690X000009Yu2qQAC.png

View solution in original post

19 REPLIES 19
MFend
Associate III

Where is LDFLAGS (linker flags) set?

MFend
Associate III

I've been asked to introduce this new IDE to the other FW developers on our team.

I still have this float-printf problem .

0690X000009YoojQAC.jpg

Even after I choose the settings, I get the error...

MFend
Associate III

The linker command shown in the console window:

arm-none-eabi-g++ -o 4040D_STM32Cube.elf Drivers\STM32L4xx_HAL_Driver\Src\stm32l4xx_hal.o

...

...

Src\values_log.o startup_stm32l451xx.o -mcpu=cortex-m4 -TF:\work\FlameDetectors\4040D_STM32Cube\stm32l4_flash.ld --specs=nosys.specs -Wl,-Map=4040D_STM32Cube.map -Wl,--gc-sections -static --specs=nano.specs -mfpu=fpv4-sp-d16 -mfloat-abi=hard -mthumb -u _printf_float -u _scanf_float -Wl,--start-group -lc -lm -lstdc++ -lsupc++ -Wl,--end-group 

In the linker command I see that -u_printf_float is defined - and still I get the errors that printf doesn't support float!!!

Gpeti
Senior II

You are using "newlib-nano" standard C library and it doesn't support float printf anyway. So even if you fix your compilation / link option issue, it will not work (for example a printf of a float will return 0.0000).

if I remember correctly (not sure though), "newlib" should support float printf.

MFend
Associate III

Thanks for noticing that...

I changed the library to the regular C/C++ standard, and I still get the error. (I Rebuilt the whole project)

" It compiles, though and can be run" So it is a build error or not ? It's not clear. And can you printf float variables at the end ?

I checked on a project of mine and there is indeed an error message in the Problems tab. To be honest I never look at this tab and I'm not sure it is reliable in this IDE.

MFend
Associate III

As you've seen yourself - these errors are mentioned, but the project can be debugged.

I haven't been able to see the printfs in the SWV console - that's another thread that I opened in the forum...

0690X000009YpHNQA0.jpg

There is the known bug about stack, see for example this thread:

https://community.st.com/s/question/0D50X0000AldaPzSQI/cubeide-sprintf-does-not-work-with-f