3
votes

I'm sort of stumped. This is the error I'm getting from gcc

gcc -lm -g -o bin/tomashell obj/tomashell.o
obj/tomashell.o: In function `_start':
(.text+0x0): multiple definition of `_start'
/usr/bin/ld: /usr/lib/debug/usr/lib/crt1.o(.debug_info): relocation 0 has invalid symbol index 12
/usr/bin/ld: /usr/lib/debug/usr/lib/crt1.o(.debug_info): relocation 1 has invalid symbol index 13
/usr/bin/ld: /usr/lib/debug/usr/lib/crt1.o(.debug_info): relocation 2 has invalid symbol index 2
/usr/bin/ld: /usr/lib/debug/usr/lib/crt1.o(.debug_info): relocation 3 has invalid symbol index 2
/usr/bin/ld: /usr/lib/debug/usr/lib/crt1.o(.debug_info): relocation 4 has invalid symbol index 12
/usr/bin/ld: /usr/lib/debug/usr/lib/crt1.o(.debug_info): relocation 5 has invalid symbol index 14
/usr/bin/ld: /usr/lib/debug/usr/lib/crt1.o(.debug_info): relocation 6 has invalid symbol index 14
/usr/bin/ld: /usr/lib/debug/usr/lib/crt1.o(.debug_info): relocation 7 has invalid symbol index 14
/usr/bin/ld: /usr/lib/debug/usr/lib/crt1.o(.debug_info): relocation 8 has invalid symbol index 2
/usr/bin/ld: /usr/lib/debug/usr/lib/crt1.o(.debug_info): relocation 9 has invalid symbol index 2
/usr/bin/ld: /usr/lib/debug/usr/lib/crt1.o(.debug_info): relocation 10 has invalid symbol index 13
/usr/bin/ld: /usr/lib/debug/usr/lib/crt1.o(.debug_info): relocation 11 has invalid symbol index 14
/usr/bin/ld: /usr/lib/debug/usr/lib/crt1.o(.debug_info): relocation 12 has invalid symbol index 14
/usr/bin/ld: /usr/lib/debug/usr/lib/crt1.o(.debug_info): relocation 13 has invalid symbol index 14
/usr/bin/ld: /usr/lib/debug/usr/lib/crt1.o(.debug_info): relocation 14 has invalid symbol index 14
/usr/bin/ld: /usr/lib/debug/usr/lib/crt1.o(.debug_info): relocation 15 has invalid symbol index 14
/usr/bin/ld: /usr/lib/debug/usr/lib/crt1.o(.debug_info): relocation 16 has invalid symbol index 14
/usr/bin/ld: /usr/lib/debug/usr/lib/crt1.o(.debug_info): relocation 17 has invalid symbol index 14
/usr/bin/ld: /usr/lib/debug/usr/lib/crt1.o(.debug_info): relocation 18 has invalid symbol index 14
/usr/bin/ld: /usr/lib/debug/usr/lib/crt1.o(.debug_info): relocation 19 has invalid symbol index 14
/usr/bin/ld: /usr/lib/debug/usr/lib/crt1.o(.debug_info): relocation 20 has invalid symbol index 14
/usr/bin/ld: /usr/lib/debug/usr/lib/crt1.o(.debug_info): relocation 21 has invalid symbol index 14
/usr/bin/ld: /usr/lib/debug/usr/lib/crt1.o(.debug_info): relocation 22 has invalid symbol index 22
/usr/bin/ld: /usr/lib/debug/usr/lib/crt1.o(.debug_line): relocation 0 has invalid symbol index 2
/usr/lib/gcc/i486-linux-gnu/4.4.5/../../../../lib/crt1.o:/build/buildd-eglibc_2.11.2-10-i386-GapcyD/eglibc-2.11.2/csu/../sysdeps/i386/elf/start.S:119: first defined here
obj/tomashell.o:(.rodata+0x0): multiple definition of `_fp_hw'
/usr/lib/gcc/i486-linux-gnu/4.4.5/../../../../lib/crt1.o:(.rodata+0x0): first defined here
obj/tomashell.o: In function `_fini':
(.fini+0x0): multiple definition of `_fini'
/usr/lib/gcc/i486-linux-gnu/4.4.5/../../../../lib/crti.o:(.fini+0x0): first defined here
obj/tomashell.o:(.rodata+0x4): multiple definition of `_IO_stdin_used'
/usr/lib/gcc/i486-linux-gnu/4.4.5/../../../../lib/crt1.o:(.rodata.cst4+0x0): first defined here
obj/tomashell.o: In function `__data_start':
(.data+0x0): multiple definition of `__data_start'
/usr/lib/gcc/i486-linux-gnu/4.4.5/../../../../lib/crt1.o:(.data+0x0): first defined here
obj/tomashell.o: In function `__data_start':
(.data+0x4): multiple definition of `__dso_handle'
/usr/lib/gcc/i486-linux-gnu/4.4.5/crtbegin.o:(.data+0x0): first defined here
obj/tomashell.o: In function `_init':
(.init+0x0): multiple definition of `_init'
/usr/lib/gcc/i486-linux-gnu/4.4.5/../../../../lib/crti.o:(.init+0x0): first defined here
/usr/lib/gcc/i486-linux-gnu/4.4.5/crtend.o:(.dtors+0x0): multiple definition of `__DTOR_END__'
obj/tomashell.o:(.dtors+0x4): first defined here
collect2: ld returned 1 exit status
make: *** [bin/tomashell] Error 1

And this is my entire code file:

#include <stdlib.h>
#include <stdio.h>

int main()
{
    printf("Hello, world!");
}

I don't have the slightest clue why this is not compiling. I'm compiling all my other C applications just fine.

1
What does your compiler invocation look like? It seems like your object file might have some stuff in it that you don't want. The fact that it appears to have _start in it, seems like you might have compiled it into an executable rather than just a simple object file like the filename extension seems to indicate.Carl Norum
Show us the command that created obj/tomashell.o , you have likely forgotten the -c flag when compiling that source file.nos
Right on, happy to have helped.Carl Norum

1 Answers

4
votes

obj/tomashell.o is not an object file but an executable file. You probably forgot to use -c when compiling it, so (by default) gcc output an executable instead of an object file.