1. 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.
    Dismiss Notice

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

Discussion in 'ARM' started by danba185, Aug 2, 2012.

  1. danba185

    danba185 New Member

    Joined:
    Aug 2, 2012
    Messages:
    1
    Likes:
    0
    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: Aug 2, 2012
  2. tgil

    tgil New Member

    Joined:
    Apr 13, 2011
    Messages:
    3
    Likes:
    0
    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.
     

Share This Page