helloworld.c无法使用100+;错误

helloworld.c无法使用100+;错误,c,configuration,ubuntu-11.10,C,Configuration,Ubuntu 11.10,我相信我正在处理某种腐败的图书馆。我编写了以下代码: //helloworld.c #include <stdio.h> int main() { printf("Hello, world!\n"); return 0; } 我犯了很多错误。以下是一个示例: /usr/include/stdio.h:510: error: expecte

我相信我正在处理某种腐败的图书馆。我编写了以下代码:

//helloworld.c                                                                  

#include <stdio.h>

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

  return 0;
}
我犯了很多错误。以下是一个示例:

/usr/include/stdio.h:510: error: expected ‘)’ before ‘*’ token
/usr/include/stdio.h:514: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘__wur’
/usr/include/stdio.h:517: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘__THROW’
/usr/include/stdio.h:524: error: expected declaration specifiers before ‘__END_NAMESPACE_C99’
/usr/include/stdio.h:534: error: expected ‘)’ before ‘*’ token
/usr/include/stdio.h:540: error: storage class specified for parameter ‘getchar’
/usr/include/stdio.h:541: error: expected declaration specifiers before ‘__END_NAMESPACE_STD’
/usr/include/stdio.h:553: error: storage class specified for parameter ‘getchar_unlocked’
/usr/include/stdio.h:563: error: expected ‘)’ before ‘*’ token
/usr/include/stdio.h:567: error: expected declaration specifiers before ‘__BEGIN_NAMESPACE_STD’
/usr/include/stdio.h:576: error: expected declaration specifiers or ‘...’ before ‘FILE’
/usr/include/stdio.h:576: error: storage class specified for parameter ‘putc’
/usr/include/stdio.h:582: error: storage class specified for parameter ‘putchar’
/usr/include/stdio.h:583: error: expected declaration specifiers before ‘__END_NAMESPACE_STD’
/usr/include/stdio.h:604: error: expected declaration specifiers or ‘...’ before ‘FILE’
/usr/include/stdio.h:604: error: storage class specified for parameter ‘putc_unlocked’
/usr/include/stdio.h:605: error: storage class specified for parameter ‘putchar_unlocked’
/usr/include/stdio.h:612: error: expected ‘)’ before ‘*’ token
/usr/include/stdio.h:615: error: expected declaration specifiers or ‘...’ before ‘FILE’
/usr/include/stdio.h:615: error: storage class specified for parameter ‘putw’
/usr/include/stdio.h:619: error: expected declaration specifiers before ‘__BEGIN_NAMESPACE_STD’
/usr/include/stdio.h:632: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘__wur’
/usr/include/stdio.h:633: error: expected declaration specifiers before ‘__END_NAMESPACE_STD’
/usr/include/stdio.h:661: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘getdelim’
/usr/include/stdio.h:671: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘getline’
/usr/include/stdio.h:677: error: expected declaration specifiers before ‘__BEGIN_NAMESPACE_STD’
/usr/include/stdio.h:688: error: storage class specified for parameter ‘puts’
/usr/include/stdio.h:695: error: expected declaration specifiers or ‘...’ before ‘FILE’
/usr/include/stdio.h:695: error: storage class specified for parameter ‘ungetc’
/usr/include/stdio.h:702: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘fread’
/usr/include/stdio.h:708: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘fwrite’
/usr/include/stdio.h:710: error: expected declaration specifiers before ‘__END_NAMESPACE_STD’
/usr/include/stdio.h:732: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘fwrite_unlocked’
/usr/include/stdio.h:737: error: expected declaration specifiers before ‘__BEGIN_NAMESPACE_STD’
/usr/include/stdio.h:747: error: expected ‘)’ before ‘*’ token
/usr/include/stdio.h:752: error: expected ‘)’ before ‘*’ token
/usr/include/stdio.h:753: error: expected declaration specifiers before ‘__END_NAMESPACE_STD’
/usr/include/stdio.h:771: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘ftello’
/usr/include/stdio.h:785: error: expected declaration specifiers before ‘__BEGIN_NAMESPACE_STD’
/usr/include/stdio.h:796: error: expected ‘)’ before ‘*’ token
/usr/include/stdio.h:808: error: expected declaration specifiers before ‘__END_NAMESPACE_STD’
/usr/include/stdio.h:821: error: expected ‘)’ before ‘*’ token
/usr/include/stdio.h:823: error: expected ‘)’ before ‘*’ token
/usr/include/stdio.h:824: error: expected declaration specifiers before ‘__END_NAMESPACE_STD’
/usr/include/stdio.h:829: error: expected ‘)’ before ‘*’ token
/usr/include/stdio.h:830: error: expected ‘)’ before ‘*’ token
/usr/include/stdio.h:834: error: expected declaration specifiers before ‘__BEGIN_NAMESPACE_STD’
/usr/include/stdio.h:840: error: expected declaration specifiers before ‘__END_NAMESPACE_STD’
/usr/include/stdio.h:846:30: error: bits/sys_errlist.h: No such file or directory
/usr/include/stdio.h:856: error: expected ‘)’ before ‘*’ token
/usr/include/stdio.h:866: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘*’ token
/usr/include/stdio.h:872: error: expected ‘)’ before ‘*’ token
/usr/include/stdio.h:878: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘__THROW’
/usr/include/stdio.h:906: error: expected ‘)’ before ‘*’ token
/usr/include/stdio.h:910: error: expected ‘)’ before ‘*’ token
/usr/include/stdio.h:913: error: expected ‘)’ before ‘*’ token
/usr/include/stdio.h:936: error: expected declaration specifiers before ‘__END_DECLS’
helloworld.c:10: error: old-style parameter declarations in prototyped function definition
helloworld.c:10: error: expected ‘{’ at end of input
FWIW,我正在运行Ubuntu11.10;最近的安装。我猜想在安装时我没有做到一些事情,但我以前从未遇到过这个问题。如果您有任何建议,我将不胜感激,并能回答您可能需要帮助我澄清/缩小问题范围的任何问题。再次感谢

编辑:谢谢你们的建议,伙计们,但我还是迷路了。我已经卸载/重新安装了libc dev bin、libc6 dev、gcc和dpkg。有人建议我问包经理crt1.o和crti.o在哪里,但我恐怕不知道怎么做


除了重新安装Ubuntu之外,有没有一种可靠的、暴力的方式来完全重建所有的库和头文件?如果没有,我可能会决定重新安装。

您几乎必须有一组损坏的头文件。要确认,请尝试以下操作:

extern int printf(char *, ...);
int main() {
    printf("hello world!\n");
    return 0;
}

如果编译得很干净,可能会导致
stdio.h
或其中一个文件损坏。如果输出二进制文件运行并产生预期的输出,那么乍一看,库本身看起来是正常的。

在11.10的干净安装上不会发生这种情况(刚刚选中)。我将删除并重新安装gcc和头文件。使用您发布的代码,我得到以下信息:hellotest.c:在函数“main”中:hellotest.c:2:警告:“main”的返回类型不是“int”/usr/bin/ld:找不到crt1.o:没有这样的文件或目录/usr/bin/ld:找不到crti.o:没有这样的文件或目录collect2:ld返回1退出状态我将main更改为int并添加了返回0;最后,get:/usr/bin/ld:找不到crt1.o:没有这样的文件或目录/usr/bin/ld:找不到crti.o:没有这样的文件或目录collect2:ld返回了1个退出状态,那么对此有什么适当的修复方法?我已经非常确定这个问题。第一个警告来自编译器,说我的main声明有点不正确。(我很快就会解决这个问题。)其余的对我来说意味着,除了损坏的头,您似乎也有损坏的库。我真的不知道该建议什么。你能强制重新安装一些基本的libc软件包吗?也许你的编译器也是如此?@FrankHarris:还有一些想法。如果你找不到
crt1.o
,有些事情很奇怪,但它解释了为什么其他程序可以工作。它们已经被链接到
crt1.o
上,或者是当它们来自的包被构建时,或者是在这之前编译它们时。您最近是否升级了系统或安装/升级了任何软件包?试着询问软件包经理哪些软件包提供了
crt1.o
crti.o
,并考虑重新安装。接受……如果可能晚了很多个月。上学期末,我在$PATH中添加了一些东西,基本上提供了一个额外的crt1.o。我把它从我的路径上移除,问题就解决了。
extern int printf(char *, ...);
int main() {
    printf("hello world!\n");
    return 0;
}