cancel
Showing results for 
Search instead for 
Did you mean: 

STM32IDE cannot sometimes find an included linker file

MO94
Visitor

I have a complex project that has multiple sub-projects inside. One of these projects has an additional .ld file called "STM32L431KCUX_SHARED.ld". This file is a linked resource in other sub-projects and normally it works without an issue, every "STM32L431KCUX_FLASH.ld" of these sub-projects have " INCLUDE STM32L431KCUx_SHARED.ld" manually inserted. The SHARED file is in the same folder as the FLASH file of one of the sub-projects.

The problem is, sometimes, when I generate code from IOC project, the ld.exe file refuses to see SHARED file. When I try to compile the project, all I see is:

11:33:54 **** Incremental Build of configuration Debug for project RF_QED169MHz ****

make -j8 all

arm-none-eabi-g++ -o "RF_QED169MHz.elf" @"objects.list" -mcpu=cortex-m4 -T"C:\[REDACTED]\rfqed_169\RF_QED169MHz\STM32L431KCUX_FLASH.ld" --specs=nosys.specs -Wl,-Map="RF_QED169MHz.map" -Wl,--gc-sections -static --specs=nano.specs -mfpu=fpv4-sp-d16 -mfloat-abi=hard -mthumb -Wl,--start-group -lc -lm -lstdc++ -lsupc++ -Wl,--end-group

C:/ST/STM32CubeIDE_1.15.1/STM32CubeIDE/plugins/com.st.stm32cube.ide.mcu.externaltools.gnu-tools-for-stm32.12.3.rel1.win32_1.0.200.202406191623/tools/bin/../lib/gcc/arm-none-eabi/12.3.1/../../../../arm-none-eabi/bin/ld.exe: cannot open linker script file STM32L431KCUx_SHARED.ld: No such file or directory

collect2.exe: error: ld returned 1 exit status

make: *** [makefile:98: RF_QED169MHz.elf] Error 1

"make -j8 all" terminated with exit code 2. Build might be incomplete.

 

This is extremely confusing as it is simply cannot be true. Code regeneration did not touch any of the linker files and the SHARED file is still linked, the file is still there where it was.

My only guess is that ld.exe starts to look for this file somewhere else, but it is not reported in the log. I can fix this issue by resetting all changes using git, but I would prefer to understand what is happening here rather than nuking my work and starting from scratch every time it happens...

I tried to copy the SHARED file in the same folder as the linker file of the sub-project I am trying to compile, with no effect.

1 ACCEPTED SOLUTION

Accepted Solutions
MO94
Visitor

It seems that I managed to resolve the issue. The error does not appear when the sub-project folder with the SHARED linker file is added to the "Library search path" of the "C/C++ Build -> Settings -> MCU G++ Linker -> Libraries" menu.

I did not expect a supplementary linker file to be considered a "library" but it makes sense. It is strange that it would sometimes work without explicitly specifying this path.

I think I am going to flag this as a solution for now, hopefully the issue will not reappear anymore.

View solution in original post

4 REPLIES 4
Imen.D
ST Employee

Hello @MO94 ,

Make sure not to use spaces or special characters in the project path of the linker script file, as this may not be recognized by the compiler.

So, use shorter path and update the project settings with the new path.

When your question is answered, please close this topic by clicking "Accept as Solution".
Thanks
Imen

I changed the project path to C:/A/%PROJECT, the error is still present.

 

arm-none-eabi-g++ -o "RF_QED169MHz.elf" @"objects.list" -mcpu=cortex-m4 -T"C:\A\rfqed169\RF_QED169MHz\STM32L431KCUX_FLASH.ld" --specs=nosys.specs -Wl,-Map="RF_QED169MHz.map" -Wl,--gc-sections -static --specs=nano.specs -mfpu=fpv4-sp-d16 -mfloat-abi=hard -mthumb -Wl,--start-group -lc -lm -lstdc++ -lsupc++ -Wl,--end-group

C:/ST/STM32CubeIDE_1.15.1/STM32CubeIDE/plugins/com.st.stm32cube.ide.mcu.externaltools.gnu-tools-for-stm32.12.3.rel1.win32_1.0.200.202406191623/tools/bin/../lib/gcc/arm-none-eabi/12.3.1/../../../../arm-none-eabi/bin/ld.exe: cannot open linker script file STM32L431KCUx_SHARED.ld: No such file or directory

collect2.exe: error: ld returned 1 exit status

make: *** [makefile:98: RF_QED169MHz.elf] Error 1

My main linker file is set to "${workspace_loc:/${ProjName}/STM32L431KCUX_FLASH.ld}" and is being found correctly.

Can '_' in the sub-project folder names interfere with the IDE?

TDK
Guru

> STM32L431KCUx_SHARED.ld

> STM32L431KCUX_SHARED.ld

I have noticed linker filenames are case sensitive to some degree. Try being consistent here.

If you feel a post has answered your question, please click "Accept as Solution".
MO94
Visitor

It seems that I managed to resolve the issue. The error does not appear when the sub-project folder with the SHARED linker file is added to the "Library search path" of the "C/C++ Build -> Settings -> MCU G++ Linker -> Libraries" menu.

I did not expect a supplementary linker file to be considered a "library" but it makes sense. It is strange that it would sometimes work without explicitly specifying this path.

I think I am going to flag this as a solution for now, hopefully the issue will not reappear anymore.