"No such file or directory" error in CMake build using arm-none-eabi

Hi Everyone,

I am new here and trying to get my STM32WL55 project build using CMake.
It’s my first trying to use CMake with STM32CubeMx and I have experienced it in ZephyrRTOS.
After read many topics on google, I have written the CMakeLists.txt in my project then tried to build it.
What I am getting now is the building error, it shows the object file path without ‘slash’ like this.

arm-none-eabi-gcc.exe: error: CMakeFilesmyproject.elf.dirCoreSrcapp_freertos.c.obj: No such file or directory
It repeats every *.obj file. :frowning:

I think the path should be like CMakeFiles\myproject.elf.dir\Core\Src\app_freertos.c.obj.
But all of the object files exist in the right place.

Does anyone have any idea?

Thanks in advance.

After changes lots of things in CMakeLists.txt, it was gone away.
Not sure what is the reason.


When specifying any path in a file read by CMake (e.g. CMakeLists.txt, any *.cmake file), use forward slashes (/) in paths, not backslashes (). When CMake parses a string, it will treat a backslash as escaping the following character. Internally, CMake uses forward slashes for paths, even on Windows.

Thanks @craig.scott

As I mentioned, I can get build now, but weird why didn’t get such errors before.
Yes, I agreed with the slash(/), not backslash(). I guessed it might be backslash on Windows. It’s my fault :wink:

It took me a couple of days to get building the assemble file(startup_xxx.S for the STM32 MCU), okay now.

I could fix it target_link_libraries instead of target_link_options.

Thank you