2024-10-07 02:57 AM - edited 2024-10-07 03:04 AM
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.
Solved! Go to Solution.
2024-10-07 05:07 AM - edited 2024-10-07 05:10 AM
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.
2024-10-07 04:10 AM
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.
2024-10-07 04:47 AM
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?
2024-10-07 05:01 AM
> STM32L431KCUx_SHARED.ld
> STM32L431KCUX_SHARED.ld
I have noticed linker filenames are case sensitive to some degree. Try being consistent here.
2024-10-07 05:07 AM - edited 2024-10-07 05:10 AM
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.