2025-07-09 9:54 PM
Today, while using the CubeMX product, I upgraded to version 6.15.0 (previously 6.14.1). After upgrade, the CMake step when generating project code failed. Even when generating an empty project, CMake still did not succeed. I also tried previously working projects that had been successfully flashed before, but they also failed during the CMake step.
The following error message was displayed:
CMake Error at D:/Program Files/JetBrains/CLion/bin/cmake/win/x64/share/cmake-3.31/Modules/CMakeTestCCompiler.cmake:67 (message): The C compiler "C:/Program Files/GNU-Arm-Toolchain-eabi/bin/arm-none-eabi-gcc.exe" is not able to compile a simple test program. It fails with the following output: Change Dir: 'D:/project/keysking/P10_Clock/clock/cmake-build-debug/CMakeFiles/CMakeScratch/TryCompile-q0iun1' Run Build Command(s): "D:/Program Files/JetBrains/CLion/bin/ninja/win/x64/ninja.exe" -v cmTC_47519 [1/2] C:\PROGRA~1\GNU-AR~1\bin\AR19DD~1.EXE -std=gnu11 -fdiagnostics-color=always -o CMakeFiles/cmTC_47519.dir/testCCompiler.c.obj -c D:/project/keysking/P10_Clock/clock/cmake-build-debug/CMakeFiles/CMakeScratch/TryCompile-q0iun1/testCCompiler.c [2/2] C:\WINDOWS\system32\cmd.exe /C "cd . && C:\PROGRA~1\GNU-AR~1\bin\AR19DD~1.EXE CMakeFiles/cmTC_47519.dir/testCCompiler.c.obj -o cmTC_47519.exe -Wl,--out-implib,libcmTC_47519.dll.a -Wl,--major-image-version,0,--minor-image-version,0 -lkernel32 -luser32 -lgdi32 -lwinspool -lshell32 -lole32 -loleaut32 -luuid -lcomdlg32 -ladvapi32 && cd ." FAILED: cmTC_47519.exe C:\WINDOWS\system32\cmd.exe /C "cd . && C:\PROGRA~1\GNU-AR~1\bin\AR19DD~1.EXE CMakeFiles/cmTC_47519.dir/testCCompiler.c.obj -o cmTC_47519.exe -Wl,--out-implib,libcmTC_47519.dll.a -Wl,--major-image-version,0,--minor-image-version,0 -lkernel32 -luser32 -lgdi32 -lwinspool -lshell32 -lole32 -loleaut32 -luuid -lcomdlg32 -ladvapi32 && cd ." C:/PROGRA~1/GNU-AR~1/bin/../lib/gcc/arm-none-eabi/14.3.1/../../../../arm-none-eabi/bin/ld.exe: unrecognized option '--major-image-version' C:/PROGRA~1/GNU-AR~1/bin/../lib/gcc/arm-none-eabi/14.3.1/../../../../arm-none-eabi/bin/ld.exe: use the --help option for usage information collect2.exe: error: ld returned 1 exit status ninja: build stopped: subcommand failed. CMake will not be able to correctly generate this project. Call Stack (most recent call first): CMakeLists.txt:28 (project)
File .ioc as follows.
Solved! Go to Solution.
2025-07-22 5:05 AM
Thank you!
I met the same question today. And I found your solution. It's so helpful.
2025-07-22 5:43 AM
Hello, @Ghofrane GSOURI
I just saw your message after finishing my vacation. I think your answer has successfully resolved this question. Previously, the toolchains I used were indeed set in CMakeLists.txt. I will try to use the new function.
Thank you very much for your solution!
Mocozzz
2025-08-06 9:11 AM - edited 2025-08-06 9:13 AM
Hello,
I'm a CLion developer. I have just verified, starm-clang toolchain works with CLion as a charm.
You don’t need to specify any toolchains using the -D switch. Everything is already configured via CMakePresets.json. These presets are automatically imported into CLion as CMake profiles—you can see them in the screenshot. Simply delete the default "Debug" profile and enable the "Debug - Debug" one instead. This process is documented here:
https://www.jetbrains.com/help/clion/embedded-stm32.html#new-project
In the upcoming CLion versions this step will be done automatically.
If you have any questions related to CLion and STM32, feel free to reach out to me directly.