通过在makefile中包含静态库来麻烦
在我们的手写的makefile中包括一个静态库,我会遇到一些麻烦。
我们希望包括目录中的lib:stl_lib.a:library/stm32_safety_stl/lib 因此,我将这一行写入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)
...
当我致电Makefile时,我会收到此错误:
ARM -NONE -NONE -AEBI -GCC.EXE -DSTM32L4R5XX -DUSE_HAL_DRIVER -DDEBUG -D HAL/CUBEMX/STM32L4R5VGTX_FLASH.LED -L library/stm32_safety_stl/libry/stm32_safety_stl/lib -mcpu = cortex -cortex -cortex -cortex -cortex -matumbi = cortex -cortumbi = cortex -ummtumbu = = fpv4-sp-d16 -wl, - gc-sections-static -wl, - start-group -lc -lm -lstl_lib -wl-wl, - end-group -specs = nosys.specs.specs -wl,-wl,-map =“ ./ develop/debug/mcu1_develop.map” -o./develop/debug/mcu1_develop.elf C:\ ST \ STM32Cubeide_1.8.0 \ STM32Cubeide \ Plugins \ com.st.st.st.stm32cube.ide.mcu.mcu.externaltools.gnu-tools-tools-for-stm32.9-2020-q2-22020-q2-update.win32_win32_2.0.0.0.0.0.0.20210531131346 \ ARM \ ARM -none -eabi \ bin \ ld.exe:找不到-lstl_lib collect2.exe:错误:ld返回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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
该错误消息的关键部分是:
,
-lstl_lib
指示链接器在库搜索路径中搜索名为libstl_lib.a
的文件。如果您所描述的确实命名了感兴趣的图书馆:...然后您无法通过标准
-L
选项将其指定给链接器。名称的形式对此是不正确的。有多个替代方案,但最简单的是只给图书馆提供完整的路径:
library/stm32_safety_stl/lib/stl_lib.a
。在这种情况下,您可能不需要-L库/STM32_SAFETY_STL/LIB
选项。The key part of that error message is:
Since you have specified static linking,
-lSTL_Lib
instructs the linker to search for a file namedlibSTL_Lib.a
in the library search path and link it. If the library of interest is indeed named as you describe:... 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.