C program no longer compiles on Ubuntu

I made a program in C and I get these errors when compiling using gcc. I have not used them until recently, and my program has not changed.

In function `_fini': (.fini+0x0): multiple definition of `_fini' /usr/lib/gcc/x86_64-linux-gnu/4.6/../../../x86_64-linux-gnu/crti.o:(.fini+0x0): first defined here slots: In function `__data_start': (.data+0x0): multiple definition of `__data_start' /usr/lib/gcc/x86_64-linux-gnu/4.6/../../../x86_64-linux-gnu/crt1.o:(.data+0x0): first defined here slots: In function `__data_start': (.data+0x8): multiple definition of `__dso_handle' /usr/lib/gcc/x86_64-linux-gnu/4.6/crtbegin.o:(.data+0x0): first defined here slots:(.rodata+0x0): multiple definition of `_IO_stdin_used' /usr/lib/gcc/x86_64-linux-gnu/4.6/../../../x86_64-linux-gnu/crt1.o:(.rodata.cst4+0x0): first defined here slots: In function `_start': (.text+0x0): multiple definition of `_start' /usr/lib/gcc/x86_64-linux-gnu/4.6/../../../x86_64-linux-gnu/crt1.o:(.text+0x0): first defined here slots: In function `_init': (.init+0x0): multiple definition of `_init' /usr/lib/gcc/x86_64-linux-gnu/4.6/../../../x86_64-linux-gnu/crti.o:(.init+0x0): first defined here /tmp/ccIlRWIn.o: In function `main': slots.c:(.text+0x0): multiple definition of `main' slots:(.text+0xe4): first defined here /usr/lib/gcc/x86_64-linux-gnu/4.6/crtend.o:(.dtors+0x0): multiple definition of `__DTOR_END__' slots:(.dtors+0x8): first defined here /usr/bin/ld: error in slots(.eh_frame); no .eh_frame_hdr table will be created. collect2: ld returned 1 exit status 
+4
source share
3 answers

You forgot -o in front of the output file name so that the linker tries to use your old executable as input.

+6
source

It seems you have more than one main and some other functions in your code. Make sure you do not include several definitions of the main file more than once in your file.

0
source

You could probably define the extern variable in the header file and include it in another file.

For instance,

 extern int _fini = 1; // declared in ah 

Say in a1.c or a2.c

 #include "ah" // _fini again defined in a1.c or a2.c 
0
source

All Articles