2025-09-09 3:19 AM
Hi,
I have upgraded recently to STM32CubeMX 6.15 on Linux and regenerate code for my STM32G491RE project (that uses iostream). Since this, it gives me compilation errors on missing libc symbols (for example putwc).
After investigations, it seems the linker script generated has changed and I wonder if it is expected.
Last part of the script has changed from:
/DISCARD/ :
{
libc.a ( * )
libm.a ( * )
libgcc.a ( * )
}
to
/DISCARD/ :
{
libc.a:* ( * )
libm.a:* ( * )
libgcc.a:* ( * )
}
Could you confirm this is valid and the expected behavior of the new declaration ?
Regards
Solved! Go to Solution.
2025-09-12 1:19 AM
Hello @Ykrons
STM32CubeMX is primarily designed for embedded C projects, where the use of the standard C++ library—especially its I/O components—is uncommon. The default linker script is intentionally kept minimal to optimize code size and memory usage, which is critical in resource-constrained embedded environments. When you switch to C++ and utilize features like <iostream>, you are introducing functionality that is not typically supported on microcontrollers, as they generally lack an operating system, file system, or standard console output.
Therefore, this behavior is not a bug in STM32CubeMX, but rather a reflection of its focus on typical embedded development practices.
THX
Ghofrane
To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.
2025-09-09 3:23 AM
Welcome to the forum
Please see How to write your question to maximize your chances to find a solution for best results
What version of CubeMX did you upgrade from ?
Not clear if you're trying to use an old CubeMX Project (ioc file) in your new CubeMX ?
If you create a new project from scratch using the the new CubeMX, does that work?
2025-09-09 3:25 AM - edited 2025-09-09 3:26 AM
Hello @Ykrons
Could you please provide more details about the version of you operating system ?
THX
Ghofrane
To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.
2025-09-09 4:50 AM
Hi,
Sorry I have missed a lot of details.
First, I'm using STM32CubeMX v6.15 installed on XUbuntu 24.04.03. CMake is v3.28.3 and gcc v14.2 from arm.
I'm creating a new project in STM32CubeMX for Nucleo-G491RE board keeping all default options, then changes Toolchain/IDE to "CMake" and generate the code.
Then I can successfully build with:
Then I'm adding C++ iostream usage:
A rebuild now fails reporting undefined reference for putwc/getwc.
Then I change the linker script to end with the following extract (:* removed) and it solves the compilation failure:
/DISCARD/ :
{
libc.a ( * )
libm.a ( * )
libgcc.a ( * )
}
Regards
2025-09-12 1:19 AM
Hello @Ykrons
STM32CubeMX is primarily designed for embedded C projects, where the use of the standard C++ library—especially its I/O components—is uncommon. The default linker script is intentionally kept minimal to optimize code size and memory usage, which is critical in resource-constrained embedded environments. When you switch to C++ and utilize features like <iostream>, you are introducing functionality that is not typically supported on microcontrollers, as they generally lack an operating system, file system, or standard console output.
Therefore, this behavior is not a bug in STM32CubeMX, but rather a reflection of its focus on typical embedded development practices.
THX
Ghofrane
To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.
2025-09-12 3:34 AM
Hello @Ghofrane GSOURI ,
Thanks for those clarifications.
I fully understand iostream is not adapted to a STM32 embedded project due to its footprint, but I have used it in some test codes and I was surprised that it is not more available without notice in the release note.
It is clearer now.
Have a good day
Kind regards