6

I'm trying to code for XMC1100 based development board. I'm trying this tutorial : http://eleceng.dit.ie/frank/arm/BareMetalXMC2Go/index.html

I have downloaded the blinky.tar.gz file and unzipped. When I try "make" I'm getting this error : arm-none-eabi-ld: cannot find -lc

Here is the output of "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

I'm using Linux Mint 17 Qiana

What I am missing?

Here is my makefile :

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 
John O'M.
  • 510
  • 4
  • 6
fobus
  • 1,938
  • 8
  • 29
  • 48
  • 1
    I think your LIBSPEC is wrong. I've looked at the sample script from the site you linked and also downloaded recent (4_9-2014q4) version of the toolchain for both Linux and Windows, and your LIBSPEC doesn't match the directory structure of any of those sources. How did you install this toolchain? – John O'M. Feb 16 '15 at 05:06
  • Hi John, I have installed with apt-get. it downloads from official repo. I have changed LIBSPEC because the directory in the orginal file doesn't exist. Do you have an idea how to find the correct path for LIBSPEC? – fobus Feb 16 '15 at 11:29
  • 1
    @fobus : It will be the one containing `libc.a` which is what the `-lc` option refers to (`-lXXX` links a library named libXXX.a). – Clifford Feb 16 '15 at 20:22
  • @Clifford thanks for your response, helped me very much. here is the correct directory /usr/lib/arm-none-eabi/newlib/armv7-m It compiled right now with this directory. – fobus Feb 16 '15 at 21:05

2 Answers2

7

I met the same problem and sudo apt-get install libnewlib-arm-none-eabi helped me.

chaosink
  • 1,329
  • 13
  • 27
  • I know it's been a while since this answer was given but dude!!! you saved my life!! By the way, I was facing the same problem but trying to compile i/MX6 bare-metal code. – m4l490n Oct 26 '16 at 15:21
2

I was getting the following when trying to run a build:

/usr/lib/gcc/arm-none-eabi/4.9.3/../../../arm-none-eabi/bin/ld: cannot find -lstdc++

I had installed the packages on Ubuntu using sudo apt-get install gcc-arm-none-eabi libnewlib-arm-none-eabi make dfu-util but it seems there is one more that is required (at least for my system). After installing libstdc++-arm-none-eabi-newlib it was able to find the correct file.

Here are the files included in that package on my system:

$ apt-file show libstdc++-arm-none-eabi-newlib | grep -e "stdc++.a$"
libstdc++-arm-none-eabi-newlib: /usr/lib/arm-none-eabi/newlib/armv6-m/libstdc++.a
libstdc++-arm-none-eabi-newlib: /usr/lib/arm-none-eabi/newlib/armv7-ar/thumb/fpu/libstdc++.a
libstdc++-arm-none-eabi-newlib: /usr/lib/arm-none-eabi/newlib/armv7-ar/thumb/libstdc++.a
libstdc++-arm-none-eabi-newlib: /usr/lib/arm-none-eabi/newlib/armv7-ar/thumb/softfp/libstdc++.a
libstdc++-arm-none-eabi-newlib: /usr/lib/arm-none-eabi/newlib/armv7-m/libstdc++.a
libstdc++-arm-none-eabi-newlib: /usr/lib/arm-none-eabi/newlib/armv7e-m/fpu/libstdc++.a
libstdc++-arm-none-eabi-newlib: /usr/lib/arm-none-eabi/newlib/armv7e-m/libstdc++.a
libstdc++-arm-none-eabi-newlib: /usr/lib/arm-none-eabi/newlib/armv7e-m/softfp/libstdc++.a
libstdc++-arm-none-eabi-newlib: /usr/lib/arm-none-eabi/newlib/fpu/libstdc++.a
libstdc++-arm-none-eabi-newlib: /usr/lib/arm-none-eabi/newlib/libstdc++.a
libstdc++-arm-none-eabi-newlib: /usr/lib/arm-none-eabi/newlib/mthumb/march=armv7/mfloat-abi=hard/mfpu=vfpv3-d16/mbig-endian/libstdc++.a
libstdc++-arm-none-eabi-newlib: /usr/lib/arm-none-eabi/newlib/thumb/libstdc++.a
Greg Bray
  • 14,929
  • 12
  • 80
  • 104