# arm-elf-ld problem, undefined reference to __gccmain'

#### danba185

##### New Member
Hello, I have problems when I am trying to link together a project example which I found on the net (I have attached the important files, just type make main.elf in the terminal). There is no problem to run:

arm-elf-as -ahls -mapcs-32 crt.s -o crt.o > crt.lst
arm-elf-gcc -I. -c -fno-common -O2 -g main.c

But, when the following command is executed:
arm-elf-ld -v -lc -Map main.map -nostartfiles -T ld_flash.cmd -o main.elf crt.o main.o

I get this error message:
main.o(.text+0x1e4): In function main': home/.../main.c:153: undefined reference to `__gccmain'

I suppose it is some library problem and I have tried a lot of different ways of including libc.a, but still I have not got it to work?

/Dan

Last edited:

#### tgil

##### New Member
Since you are using -nostartfiles, none of the standard GCC/C libraries are being linked. __gccmain is a part of libgcc. You probably just need to add -lgcc after -lc.