• Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

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

Thread starter #1
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
#2
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.
 

Latest threads

EE World Online Articles

Loading

 
Top