简体   繁体   English

C程序不再在Ubuntu中编译

[英]C program no longer compiles in Ubuntu

I made a program in C and I get these errors when I compile using gcc. 我用C语言编写了一个程序,使用gcc进行编译时出现这些错误。 I did not use to get 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

您在输出文件名之前忘记了-o,因此链接器试图将您的旧可执行文件用作输入。

Seems you have more than one main and some other functions in your code. 似乎您的代码中有多个main功能和一些其他功能。 Make sure you didn't include multiple definitions of main more than once in your makefile. 确保在makefile中没有多次包含main的多个定义。

You could have probably defined an extern variable in a header file and include it in another file. 您可能已经在头文件中定义了一个extern变量,并将其包含在另一个文件中。

For example, 例如,

extern int _fini = 1;  // declared in a.h

Say in a1.c or a2.c 在a1.c或a2.c中说

#include "a.h"   // _fini again defined in a1.c or a2.c 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM