【问题标题】:Problems with arm-none-eabi linker in Eclipse using GNU MCU Eclipse Plugin使用 GNU MCU Eclipse 插件的 Eclipse 中 arm-none-eabi 链接器的问题
【发布时间】:2018-01-04 15:47:10
【问题描述】:

我在尝试为我的新 STM32F7 Nucleo 板设置的项目时遇到问题。我新安装了GNU ARM Embedded toolchainSTM32CubeF7GNU MCU Eclipse Plugin,并在我的Windows 7 机器上设置了一个新项目。我以前在家里的 Ubuntu 笔记本电脑上做过,没有任何问题。 设置项目后,我添加了 HAL 和 CMSIS 库,并使用了来自 STM32CubeF7 的模板项目。到目前为止,编译工作正常,但是在链接时出现以下错误:

c:/program files (x86)/gnu tools arm embedded/5.4 2016q2/bin/../lib/gcc/arm-none-eabi/5.4.1/../../../../arm-none-eabi/bin/ld.exe: cannot find -lc_p-lc_p

据我了解,这里的问题是找不到一些名称非常奇怪的库。不幸的是,唯一的page that I found where the same error is described 是俄语,我根本不会说。

乍一看,生成的 makefile 似乎已损坏,并且一个名为 c_p 的库正在尝试链接,但它执行了两次,中间没有空格。所以这可能是 Eclipse 或 Eclipse GNU MCU 插件的问题。

我试图摆脱错误的事情:

  • 更新 Eclipse
  • 降级到多个旧版本的 GNU ARM Embedded 工具链
  • 关闭/打开以下链接器选项:
    • --specs=nano.specs
    • -nodefaultlibs
    • -nostdlib
  • 将工具链安装在没有空格的文件夹中

这是自动生成的makefile:

################################################################################
# Automatically-generated file. Do not edit!
################################################################################

-include ../makefile.init

RM := rm -rf

# All of the sources participating in the build are defined here
-include sources.mk
-include system/src/subdir.mk
-include system/HAL/Src/subdir.mk
-include system/subdir.mk
-include src/subdir.mk
-include subdir.mk
-include objects.mk

ifneq ($(MAKECMDGOALS),clean)
ifneq ($(strip $(CC_DEPS)),)
-include $(CC_DEPS)
endif
ifneq ($(strip $(C++_DEPS)),)
-include $(C++_DEPS)
endif
ifneq ($(strip $(C_UPPER_DEPS)),)
-include $(C_UPPER_DEPS)
endif
ifneq ($(strip $(CXX_DEPS)),)
-include $(CXX_DEPS)
endif
ifneq ($(strip $(ASM_DEPS)),)
-include $(ASM_DEPS)
endif
ifneq ($(strip $(S_UPPER_DEPS)),)
-include $(S_UPPER_DEPS)
endif
ifneq ($(strip $(C_DEPS)),)
-include $(C_DEPS)
endif
ifneq ($(strip $(CPP_DEPS)),)
-include $(CPP_DEPS)
endif
endif

-include ../makefile.defs

# Add inputs and outputs from these tool invocations to the build variables 
SECONDARY_FLASH += \
stm32Template.hex \

SECONDARY_SIZE += \
stm32Template.siz \


# All Target
all: stm32Template.elf secondary-outputs

# Tool invocations
stm32Template.elf: $(OBJS) $(USER_OBJS)
    @echo 'Building target: $@'
    @echo 'Invoking: GNU ARM Cross C++ Linker'
    arm-none-eabi-g++ -mcpu=cortex-m7 -mthumb -mfloat-abi=soft -O0 -fmessage-length=0 -fsigned-char -ffunction-sections -fdata-sections -ffreestanding -fno-move-loop-invariants -Wall -Wextra  -g3 -p -pg -T mem.ld -T libs.ld -T sections.ld -nostartfiles -L"../ldscripts" -Wl,-Map,"stm32Template.map" --specs=nano.specs -o "stm32Template.elf" $(OBJS) $(USER_OBJS) $(LIBS)
    @echo 'Finished building target: $@'
    @echo ' '

stm32Template.hex: stm32Template.elf
    @echo 'Invoking: GNU ARM Cross Create Flash Image'
    arm-none-eabi-objcopy -O ihex "stm32Template.elf"  "stm32Template.hex"
    @echo 'Finished building: $@'
    @echo ' '

stm32Template.siz: stm32Template.elf
    @echo 'Invoking: GNU ARM Cross Print Size'
    arm-none-eabi-size --format=berkeley "stm32Template.elf"
    @echo 'Finished building: $@'
    @echo ' '

# Other Targets
clean:
    -$(RM) $(CC_DEPS)$(C++_DEPS)$(OBJS)$(C_UPPER_DEPS)$(CXX_DEPS)$(SECONDARY_FLASH)$(SECONDARY_SIZE)$(ASM_DEPS)$(S_UPPER_DEPS)$(C_DEPS)$(CPP_DEPS) stm32Template.elf
    -@echo ' '

secondary-outputs: $(SECONDARY_FLASH) $(SECONDARY_SIZE)

.PHONY: all clean dependents

-include ../makefile.targets

有人对此有什么意见吗?

编辑: GNU MCU Eclipse Plugin 为新项目提供了一个模板,即使这样我也会遇到同样的错误。

【问题讨论】:

    标签: c eclipse gcc arm stm32


    【解决方案1】:

    你犯了一个非常重要的错误。您尝试使用 DIY Eclipse 配置来导入为特定环境创建的项目。

    安装 OpenSTM32。 使用 SW4STM32 工具链设置生成您的项目。

    导入项目。编译、链接和调试

    如果您发现已安装的工具链已过时,您可以替换它。

    【讨论】:

    • 我没有导入任何设置,我只是复制了源文件,以便我自己设置和配置项目。我在家里做了这个,它适用于另一个项目——但在 Linux 上。问题是我想继续使用 Eclipse,就像我多年来一直在做的那样。而且我想知道为什么会发生这种情况,以便我知道问题出在哪里,是工具链还是 IDE。
    • 好的。对不起,伙计。
    • 完全不用担心,感谢您的帮助:) 我刚刚更新了我的问题,当我创建一个干净的新项目并尝试编译它时会发生同样的错误。该项目来自GNU MCU Eclipse Plugin提供的模板,所以不能因为我将文件复制到项目中。我担心它与工具链有关......
    • 如果您想了解和理解 - 为特定项目创建自己的 makefile。否则,分析自动生成的 makefile 只是浪费时间。 OpenSTM32 那些(它是 Eclipse)可以正常工作,并且受 STM 支持。我在 99% 的项目中都使用这个环境 - 并且不使用 HAL 或 SPL(仅裸寄存器)
    • 除了一些非常低级的项目(更好地称为hacks)
    【解决方案2】:

    过了一会儿,我想出了如何解决这个问题,但不幸的是,我还没有找到究竟是什么原因造成的。我搜索了我的GNU ARM Embedded toolchain 安装文件夹,没有找到任何包含c_p 的库名称。我认为这个问题的原因一定在于定义了链接器的默认库,这就是为什么我认为问题在于工具链本身。

    但是,我选择禁用默认库(-nodefaultlibs 标志)并自己链接它们。我链接了以下库:

    -lg -lstdc++ -lgcc -lm -lrdimon -lc

    如果有人能帮我找到这个问题的真正根源,将不胜感激。 但是,既然它解决了我的问题,我将关闭这个问题。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-05-01
      • 2017-03-24
      • 1970-01-01
      • 2015-07-01
      • 2017-10-10
      • 2022-01-14
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多