c - 使用 GNU MCU Eclipse 插件的 Eclipse 中的 arm-none-eabi 链接器问题

标签 c eclipse gcc arm stm32

我在尝试为新的 STM32F7 Nucleo 板设置项目时遇到问题。我新安装了GNU ARM Embedded toolchain , STM32CubeF7GNU 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 嵌入式工具链的多个旧版本
  • 关闭/打开以下链接器选项:
    • --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 插件为新项目提供了一个模板,即使这样我也遇到了同样的错误。

最佳答案

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

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

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

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

关于c - 使用 GNU MCU Eclipse 插件的 Eclipse 中的 arm-none-eabi 链接器问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45375769/

相关文章:

ios - 配置脚本和ldid

java - Java 和 C 之间传递值

eclipse - 通过命令行刷新eclipse项目

java - 添加源代码来构建路径?

c - 海湾合作委员会的输出

c - 在运行时重定位函数 - gcc

使用预增量或后增量运算符的情况

C结构: member order and memory allocation

C++ 如何将整数和长整型转换为 char 数组

c++ - 无法解析类型 'GLchar'