cancel
Showing results for 
Search instead for 
Did you mean: 

Compilation failure after upgrade to STM32CubeMX 6.15

Ykrons
Associate II

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

 

1 ACCEPTED SOLUTION

Accepted Solutions

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.

View solution in original post

5 REPLIES 5
Andrew Neil
Super User

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?

A complex system that works is invariably found to have evolved from a simple system that worked.
A complex system designed from scratch never works and cannot be patched up to make it work.
Ghofrane GSOURI
ST Employee

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.

Ykrons
Associate II

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:

  • cmake -DCMAKE_BUILD_TYPE=Debug -DCMAKE_TOOLCHAIN_FILE=cmake/gcc-arm-none-eabi.cmake -G "Unix Makefiles" -S . -B build/
  • cmake --build build

Then I'm adding C++ iostream usage:

  • I rename main.c into main.cpp (and update the CMakeLists.txt accordingly) to switch to C++
  • I add iostream usage in main.cpp:
    • #include <iostream> at the top
    • std::cout << "Test" << std::endl; somewhere in the main method

A rebuild now fails reporting undefined reference for putwc/getwc.

Ykrons_0-1757417761280.png

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

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.

Ykrons
Associate II

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