通过在makefile中包含静态库来麻烦

发布于 2025-02-03 16:37:30 字数 1363 浏览 3 评论 0原文

在我们的手写的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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

彡翼 2025-02-10 16:37:30

该错误消息的关键部分是:

找不到-lstl_lib

-lstl_lib指示链接器在库搜索路径中搜索名为libstl_lib.a的文件。如果您所描述的确实命名了感兴趣的图书馆:

我们要包含lib:stl_lib.a,它在目录中:library/stm32_safety_stl/lib

...然后您无法通过标准-L选项将其指定给链接器。名称的形式对此是不正确的。

有多个替代方案,但最简单的是只给图书馆提供完整的路径:library/stm32_safety_stl/lib/stl_lib.a。在这种情况下,您可能不需要-L库/STM32_SAFETY_STL/LIB选项。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文