Reputation: 1
I have some troubles by including a static library in our handwritten makefile.
We want include the lib: STL_lib.a which is in the directory: Library/STM32_Safety_STL/Lib So I wrote this line into the makefile:
...
LDFLAGS_END += -Wl,--gc-sections -static -Wl,--start-group -lc -lm -lSTL_Lib -Wl,--end-group --specs=nosys.specs
...
LDLIBS := Library/STM32_Safety_STL/Lib
...
$$(BUILD_DIR)/$1.elf : $$(OBJECTS) | $$(BUILD_DIR)
@echo ' '
$$(LD) \
$$(DEFS) \
-T $$(LDSCRIPTS) \
-L $$(LDLIBS) \
$$(LDFLAGS) \
$$(LDFLAGS_END) \
$$(MAP_FILE) \
-o $$(@) $$(OBJECTS)
...
When I call the makefile, I get this error:
arm-none-eabi-gcc.exe -DSTM32L4R5xx -DUSE_HAL_DRIVER -DDEBUG -T HAL/CubeMX/STM32L4R5VGTX_FLASH.ld -L Library/STM32_Safety_STL/Lib -mcpu=cortex-m4 -mthumb -mfloat-abi=hard -mfpu=fpv4-sp-d16 -Wl,--gc-sections -static -Wl,--start-group -lc -lm -lSTL_Lib -Wl,--end-group --specs=nosys.specs -Wl,-Map="./Develop/Debug/MCU1_Develop.map" -o ./Develop/Debug/MCU1_Develop.elf c:\st\stm32cubeide_1.8.0\stm32cubeide\plugins\com.st.stm32cube.ide.mcu.externaltools.gnu-tools-for-stm32.9-2020-q2-update.win32_2.0.0.202105311346\tools\arm-none-eabi\bin\ld.exe: cannot find -lSTL_Lib collect2.exe: error: ld returned 1 exit status
Can anyone give me a hint? :) Thank you
Upvotes: 0
Views: 328
Reputation: 180048
The key part of that error message is:
cannot find -lSTL_Lib
Since you have specified static linking, -lSTL_Lib
instructs the linker to search for a file named libSTL_Lib.a
in the library search path and link it. If the library of interest is indeed named as you describe:
We want include the lib: STL_lib.a which is in the directory: Library/STM32_Safety_STL/Lib
... then you cannot designate it to the linker via a standard -l
option. The form of the name is incorrect for that.
There is more than one alternative, but perhaps simplest would be to just give a full path to the library instead: Library/STM32_Safety_STL/Lib/STL_lib.a
. In that case, you might not need the -L Library/STM32_Safety_STL/Lib
option.
Upvotes: 1