cancel
Showing results for 
Search instead for 
Did you mean: 

CMAKE build works only in IDE

JKol
Associate II

Hello,
I have successfully created a new cmake project in IDE 1.16. Everything I need works - the project is successfully compiled, the BIN file is successfully run in the MCU:

[ 97%] Building C object CMakeFiles/KubergCMAKE.dir/Drivers/STM32L0xx_HAL_Driver/Src/stm32l0xx_hal_uart_ex.c.obj

[100%] Linking C executable KubergCMAKE.elf

text data bss dec hex filename

48528 128 3376 52032 cb40 C:/Projekty/KubergCMAKE/Release/KubergCMAKE.elf

[100%] Built target KubergCMAKE

 

13:57:54 Build Finished. 0 errors, 0 warnings. (took 16s.631ms)

 

However, I am unable to compile the project from the command line window.
cmake --build Release

This command only succesfuly compile source files - 100% done, but when try to lining:
[100%] Linking C executable KubergCMAKE.elf

ends with this error:

.......
............
CMakeFiles/KubergCMAKE.dir/Drivers/STM32L0xx_HAL_Driver/Src/stm32l0xx_hal_uart_ex.c.obj : No such file or directory
collect2.exe: error: ld returned 1 exit status
make[2]: *** [CMakeFiles/KubergCMAKE.dir/build.make:639: KubergCMAKE.elf] Error 1
make[1]: *** [CMakeFiles/Makefile2:83: CMakeFiles/KubergCMAKE.dir/all] Error 2

 

Has anyone solved the same problem?

Thank You, Jan.

1 ACCEPTED SOLUTION

Accepted Solutions
Souhaib MAZHOUD
ST Employee

Hello @JKol 

I suggest that you delete the Debug folder and rebuild the project with command line below:

cmake -DCMAKE_TOOLCHAIN_FILE=cubeide-gcc.cmake  -S ./ -B Debug -GUnix -DCMAKE_BUILD_TYPE=Debug

cmake --build Debug --clean-first

It seems that the project was built using an older version of CubeIDE.

KR,

Souhaib

 

View solution in original post

4 REPLIES 4
Souhaib MAZHOUD
ST Employee

Hello @JKol ,

First let me thank you for posting!

I am not able to reproduce your issue in my side, 

Could you add your project for further investigation.

Thx,

Souhaib

Hello Souhaib,

my project is based on empty project reated in IDE - STM32 CMake Project. Project is attached.

Thank you.
Jan.

JKol_0-1722489682906.png

JKol_1-1722489692651.png

 

Souhaib MAZHOUD
ST Employee

Hello @JKol 

I suggest that you delete the Debug folder and rebuild the project with command line below:

cmake -DCMAKE_TOOLCHAIN_FILE=cubeide-gcc.cmake  -S ./ -B Debug -GUnix -DCMAKE_BUILD_TYPE=Debug

cmake --build Debug --clean-first

It seems that the project was built using an older version of CubeIDE.

KR,

Souhaib

 

Hello Souhaib,

thanks a lot it's working :-). I only
1. added the path to compiler files to PATH variable:
c:\ST\STM32CubeIDE_1.13.2\STM32CubeIDE\plugins\com.st.stm32cube.ide.mcu.externaltools.gnu-tools-for-stm32.12.3.rel1.win32_1.0.200.202406191623\tools\bin
2. changed cmake command:
cmake -DCMAKE_TOOLCHAIN_FILE=cubeide-gcc.cmake -S ./ -B Debug -G"Unix Makefiles" -DCMAKE_BUILD_TYPE=Debug

Best regards,
Jan.