【发布时间】:2015-02-16 01:46:13
【问题描述】:
我正在尝试为基于 XMC1100 的开发板编写代码。 我正在尝试这个教程:http://eleceng.dit.ie/frank/arm/BareMetalXMC2Go/index.html
我已经下载了 blinky.tar.gz 文件并解压缩。当我尝试“make”时,我收到了这个错误:arm-none-eabi-ld: cannot find -lc
这是“make”的输出
arm-none-eabi-gcc -c -mcpu=cortex-m0 -mthumb -g init.c -o init.o
arm-none-eabi-gcc -c -mcpu=cortex-m0 -mthumb -g main.c -o main.o
arm-none-eabi-ld init.o main.o -L /usr/lib/gcc/arm-none-eabi/4.8.2/armv6-m -T linker_script.ld -lc --cref -Map main.map -nostartfiles -o main.elf
arm-none-eabi-ld: cannot find -lc
make: *** [main.elf] Error 1
我正在使用 Linux Mint 17 Qiana
我错过了什么?
这是我的生成文件:
LIBSPEC=-L /usr/lib/gcc/arm-none-eabi/4.8.2/armv6-m
# Specify the compiler to use
CC=arm-none-eabi-gcc
# Specify the assembler to use
AS=arm-none-eabi-as
# Specity the linker to use
LD=arm-none-eabi-ld
CCFLAGS=-mcpu=cortex-m0 -mthumb -g
# List the object files involved in this project
OBJS= init.o \
main.o
# The default 'target' (output) is main.elf and it depends on the object files being there.
# These object files are linked together to create main.elf
main.elf : $(OBJS)
$(LD) $(OBJS) $(LIBSPEC) -T linker_script.ld -lc --cref -Map main.map -nostartfiles -o main.elf
arm-none-eabi-objcopy -O binary main.elf main.bin
objcopy -O ihex main.elf main.hex
@echo "done"
# The object file main.o depends on main.c. main.c is compiled to make main.o
main.o: main.c
$(CC) -c $(CCFLAGS) main.c -o main.o
init.o: init.c
$(CC) -c $(CCFLAGS) init.c -o init.o
# if someone types in 'make clean' then remove all object files and executables
# associated wit this project
clean:
rm $(OBJS)
rm main.elf
rm main.bin
【问题讨论】:
-
我认为你的 LIBSPEC 是错误的。我查看了您链接的站点中的示例脚本,还下载了适用于 Linux 和 Windows 的工具链的最新 (4_9-2014q4) 版本,并且您的 LIBSPEC 与任何这些源的目录结构都不匹配。您是如何安装此工具链的?
-
嗨,约翰,我已经安装了 apt-get。它从官方仓库下载。我更改了 LIBSPEC,因为原始文件中的目录不存在。您知道如何找到 LIBSPEC 的正确路径吗?
-
@fobus :它将是包含
libc.a的那个-lc选项所指的(-lXXX链接一个名为 libXXX.a 的库)。 -
@Clifford 感谢您的回复,对我帮助很大。这是正确的目录 /usr/lib/arm-none-eabi/newlib/armv7-m 它现在用这个目录编译。