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



我正在尝试为我的新STM32F7 Nucleo Board设置一个项目时遇到问题。我新安装了GNU ARM Embedded工具链STM32CubeF7和GNU MCU Eclipse插件,我在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

据我了解,这里的问题是找不到一些名称非常奇怪的库。不幸的是,我发现唯一描述相同错误的页面是俄语,我根本不会说。

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

我试图摆脱错误的事情:

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

下面是自动生成的生成文件:

################################################################################
# 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

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

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

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

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

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

最新更新