ubuntu中gcc无法编译程序-----急急急急急急急急急急急急

C、C++和Java语言
回复
brucechou
帖子: 2
注册时间: 2007-04-10 21:33
送出感谢: 0
接收感谢: 0

ubuntu中gcc无法编译程序-----急急急急急急急急急急急急

#1

帖子 brucechou » 2007-04-10 21:39

程序如下:

#include <stdio.h>           
int main()
{
 printf(“Hello World. ”);
 exit(0);
}

编译信息如下:
jack@jack-desktop:~$ gcc -o bc bc.c
bc.c:1:17: warning: extra tokens at end of #include directive
bc.c:1:50: error: stdio: No such file or directory
bc.c:2: error: stray ‘\343’ in program
bc.c:2: error: stray ‘\200’ in program
bc.c:2: error: stray ‘\200’ in program
bc.c:2: error: stray ‘\343’ in program
bc.c:2: error: stray ‘\200’ in program
bc.c:2: error: stray ‘\200’ in program
bc.c:3: error: stray ‘\343’ in program
bc.c:3: error: stray ‘\200’ in program
bc.c:3: error: stray ‘\200’ in program
bc.c:3: error: stray ‘\343’ in program
bc.c:3: error: stray ‘\200’ in program
bc.c:3: error: stray ‘\200’ in program
bc.c:4: error: stray ‘\343’ in program
bc.c:4: error: stray ‘\200’ in program
bc.c:4: error: stray ‘\200’ in program
bc.c:4: error: stray ‘\343’ in program
bc.c:4: error: stray ‘\200’ in program
bc.c:4: error: stray ‘\200’ in program
bc.c: In function ‘main’:
bc.c:5: error: stray ‘\343’ in program
bc.c:5: error: stray ‘\200’ in program
bc.c:5: error: stray ‘\200’ in program
bc.c:5: error: stray ‘\343’ in program
bc.c:5: error: stray ‘\200’ in program
bc.c:5: error: stray ‘\200’ in program
bc.c:6: error: stray ‘\343’ in program
bc.c:6: error: stray ‘\200’ in program
bc.c:6: error: stray ‘\200’ in program
bc.c:6: error: stray ‘\343’ in program
bc.c:6: error: stray ‘\200’ in program
bc.c:6: error: stray ‘\200’ in program
bc.c:6: warning: incompatible implicit declaration of built-in function ‘printf’
bc.c:6: error: stray ‘\342’ in program
bc.c:6: error: stray ‘\200’ in program
bc.c:6: error: stray ‘\234’ in program
bc.c:6: error: ‘Hello’ undeclared (first use in this function)
bc.c:6: error: (Each undeclared identifier is reported only once
bc.c:6: error: for each function it appears in.)
bc.c:6: error: expected ‘)’ before ‘World’
bc.c:6: error: stray ‘\342’ in program
bc.c:6: error: stray ‘\200’ in program
bc.c:6: error: stray ‘\235’ in program
bc.c:6: error: stray ‘\343’ in program
bc.c:6: error: stray ‘\200’ in program
bc.c:6: error: stray ‘\200’ in program
bc.c:6: error: stray ‘\343’ in program
bc.c:6: error: stray ‘\200’ in program
bc.c:6: error: stray ‘\200’ in program
bc.c:6: error: expected expression before ‘>>’ token
bc.c:6: error: stray ‘\347’ in program
bc.c:6: error: stray ‘\216’ in program
bc.c:6: error: stray ‘\257’ in program
bc.c:6: error: stray ‘\345’ in program
bc.c:6: error: stray ‘\242’ in program
bc.c:6: error: stray ‘\203’ in program
bc.c:6: error: stray ‘\344’ in program
bc.c:6: error: stray ‘\270’ in program
bc.c:6: error: stray ‘\213’ in program
bc.c:6: error: stray ‘\357’ in program
bc.c:6: error: stray ‘\274’ in program
bc.c:6: error: stray ‘\214’ in program
bc.c:6: error: stray ‘\346’ in program
bc.c:6: error: stray ‘\214’ in program
bc.c:6: error: stray ‘\211’ in program
bc.c:6: error: stray ‘\344’ in program
bc.c:6: error: stray ‘\270’ in program
bc.c:6: error: stray ‘\213’ in program
bc.c:6: error: stray ‘\351’ in program
bc.c:6: error: stray ‘\224’ in program
bc.c:6: error: stray ‘\256’ in program
bc.c:6: error: stray ‘\357’ in program
bc.c:6: error: stray ‘\274’ in program
bc.c:6: error: stray ‘\214’ in program
bc.c:6: error: stray ‘\346’ in program
bc.c:6: error: stray ‘\234’ in program
bc.c:6: error: stray ‘\211’ in program
bc.c:6: error: stray ‘\350’ in program
bc.c:6: error: stray ‘\207’ in program
bc.c:6: error: stray ‘\252’ in program
bc.c:6: error: stray ‘\345’ in program
bc.c:6: error: stray ‘\212’ in program
bc.c:6: error: stray ‘\250’ in program
bc.c:6: error: stray ‘\347’ in program
bc.c:6: error: stray ‘\274’ in program
bc.c:6: error: stray ‘\251’ in program
bc.c:6: error: stray ‘\350’ in program
bc.c:6: error: stray ‘\277’ in program
bc.c:6: error: stray ‘\233’ in program
bc.c:6: error: stray ‘\345’ in program
bc.c:6: error: stray ‘\212’ in program
bc.c:6: error: stray ‘\237’ in program
bc.c:6: error: stray ‘\350’ in program
bc.c:6: error: stray ‘\203’ in program
bc.c:6: error: stray ‘\275’ in program
bc.c:7: error: stray ‘\343’ in program
bc.c:7: error: stray ‘\200’ in program
bc.c:7: error: stray ‘\200’ in program
bc.c:7: error: stray ‘\343’ in program
bc.c:7: error: stray ‘\200’ in program
bc.c:7: error: stray ‘\200’ in program
bc.c:8: error: stray ‘\343’ in program
bc.c:8: error: stray ‘\200’ in program
bc.c:8: error: stray ‘\200’ in program
bc.c:8: error: stray ‘\343’ in program
bc.c:8: error: stray ‘\200’ in program
bc.c:8: error: stray ‘\200’ in program
bc.c:9: error: stray ‘\343’ in program
bc.c:9: error: stray ‘\200’ in program
bc.c:9: error: stray ‘\200’ in program
bc.c:9: error: stray ‘\343’ in program
bc.c:9: error: stray ‘\200’ in program
bc.c:9: error: stray ‘\200’ in program
bc.c:10: error: stray ‘\343’ in program
bc.c:10: error: stray ‘\200’ in program
bc.c:10: error: stray ‘\200’ in program
bc.c:10: error: stray ‘\343’ in program
bc.c:10: error: stray ‘\200’ in program
bc.c:10: error: stray ‘\200’ in program

那位高手帮帮忙!
上次由 brucechou 在 2007-04-10 21:49,总共编辑 2 次。
头像
BigSnake.NET
帖子: 12522
注册时间: 2006-07-02 11:16
来自: 廣州
送出感谢: 0
接收感谢: 7 次
联系:

Re: ubuntu中gcc无法编译程序-----急急急急急急急急急急急急

#2

帖子 BigSnake.NET » 2007-04-10 21:45

brucechou 写了:程序如下:

#include <stdio>       
int main()
{
 printf(“Hello World. ”);  >>>> Emacs环境下,按下 Tab 键,有自动缩进功能
 exit(0);
}
1.stdio.h
2.把你的全角空格统统去掉
3.引号用英文的
4.谁教你这样注释的..
^_^ ~~~
要理解递归,首先要理解递归。

地球人都知道,理论上,理论跟实际是没有差别的,但实际上,理论跟实际的差别是相当大滴。
brucechou
帖子: 2
注册时间: 2007-04-10 21:33
送出感谢: 0
接收感谢: 0

#3

帖子 brucechou » 2007-04-10 21:55

不好意思刚刚发帖是输入错了。
我重新改了代码:
#include <stdio.h>           
int main()
{
 printf(“Hello World. ”);
 exit(0);
}
编译是输出如下错误:
bc.c:1:19: warning: extra tokens at end of #include directive
bc.c:1:52: error: stdio.h: No such file or directory
bc.c: In function ‘main’:
bc.c:4: error: stray ‘\343’ in program
bc.c:4: error: stray ‘\200’ in program
bc.c:4: error: stray ‘\200’ in program
bc.c:4: warning: incompatible implicit declaration of built-in function ‘printf’
dbzhang800
帖子: 3182
注册时间: 2006-03-10 15:10
来自: xi'an China
送出感谢: 0
接收感谢: 2 次
联系:

#4

帖子 dbzhang800 » 2007-04-10 22:08

先装好编译环境再说
头像
BigSnake.NET
帖子: 12522
注册时间: 2006-07-02 11:16
来自: 廣州
送出感谢: 0
接收感谢: 7 次
联系:

#5

帖子 BigSnake.NET » 2007-04-10 22:19

brucechou 写了:不好意思刚刚发帖是输入错了。
我重新改了代码:
#include <stdio.h>           
int main()
{
 printf(“Hello World. ”);
 exit(0);
}
编译是输出如下错误:
bc.c:1:19: warning: extra tokens at end of #include directive
bc.c:1:52: error: stdio.h: No such file or directory
bc.c: In function ‘main’:
bc.c:4: error: stray ‘\343’ in program
bc.c:4: error: stray ‘\200’ in program
bc.c:4: error: stray ‘\200’ in program
bc.c:4: warning: incompatible implicit declaration of built-in function ‘printf’
<stdio.h>后面一堆全角空格
引号用英文,不要用中文引号
^_^ ~~~
要理解递归,首先要理解递归。

地球人都知道,理论上,理论跟实际是没有差别的,但实际上,理论跟实际的差别是相当大滴。
reya
帖子: 40
注册时间: 2007-04-27 16:29
送出感谢: 0
接收感谢: 0

[分享]

#6

帖子 reya » 2007-06-06 20:10

将exit(0);改为return 0;
头像
arthur
帖子: 76
注册时间: 2006-08-13 16:06
送出感谢: 0
接收感谢: 0

#7

帖子 arthur » 2007-06-07 9:36

建议学C/C++者也同时补一下英文,不用精通,但是最少能够通过查字典能够看明白错误报告。
头像
diabloneo
帖子: 80
注册时间: 2006-06-06 22:56
送出感谢: 0
接收感谢: 0

#8

帖子 diabloneo » 2007-06-07 11:54

要用exit(0)的话,就要
#inlcude <stdlib.h>
头像
stlxv
论坛版主
帖子: 8273
注册时间: 2006-05-03 0:39
来自: المريخ
送出感谢: 0
接收感谢: 1 次

#9

帖子 stlxv » 2007-06-08 11:55

brucechou 写了:不好意思刚刚发帖是输入错了。
我重新改了代码:
#include <stdio.h>           
int main()
{
 printf(“Hello World. ”);
 exit(0);
}
编译是输出如下错误:
bc.c:1:19: warning: extra tokens at end of #include directive
bc.c:1:52: error: stdio.h: No such file or directory
bc.c: In function ‘main’:
bc.c:4: error: stray ‘\343’ in program
bc.c:4: error: stray ‘\200’ in program
bc.c:4: error: stray ‘\200’ in program
bc.c:4: warning: incompatible implicit declaration of built-in function ‘printf’
stdio.h找不到估计你要把libc-dev给装上
你试试把这些内容给复制粘贴到一个文本文件里面,然后再编译它:

代码: 全选

#include <stdio.h>

int main()
{
    printf("hello\n");
    return 0;
}
PHP是最好的语言!不服来战!
sczh01
帖子: 2
注册时间: 2007-03-17 11:26
送出感谢: 0
接收感谢: 0

#10

帖子 sczh01 » 2007-06-15 22:45

stlxv 写了:
brucechou 写了:不好意思刚刚发帖是输入错了。
我重新改了代码:
#include <stdio.h>           
int main()
{
 printf(“Hello World. ”);
 exit(0);
}
编译是输出如下错误:
bc.c:1:19: warning: extra tokens at end of #include directive
bc.c:1:52: error: stdio.h: No such file or directory
bc.c: In function ‘main’:
bc.c:4: error: stray ‘\343’ in program
bc.c:4: error: stray ‘\200’ in program
bc.c:4: error: stray ‘\200’ in program
bc.c:4: warning: incompatible implicit declaration of built-in function ‘printf’
stdio.h找不到估计你要把libc-dev给装上
你试试把这些内容给复制粘贴到一个文本文件里面,然后再编译它:

代码: 全选

#include <stdio.h>

int main()
{
    printf("hello\n");
    return 0;
}
谢谢 这才是正解阿
szzfq61
帖子: 6
注册时间: 2008-01-28 9:13
来自: 深圳
送出感谢: 0
接收感谢: 0
联系:

#11

帖子 szzfq61 » 2008-04-01 23:57

害死人,
把空格的部分去掉,重新加上TAB就好。
Furson
帖子: 24
注册时间: 2008-03-30 15:37
送出感谢: 0
接收感谢: 0

#12

帖子 Furson » 2008-04-12 0:07

dbzhang800 写了:先装好编译环境再说

请问怎么安装编译环境呢?
头像
飞火流星
帖子: 990
注册时间: 2010-05-11 21:50
送出感谢: 1 次
接收感谢: 2 次

Re: ubuntu中gcc无法编译程序-----急急急急急急急急急急急急

#13

帖子 飞火流星 » 2010-12-02 1:04

你是不是从网页上嗖的直接粘上去的啊?有些空格什么的会报错的
有事多折腾。。。没事瞎折腾。。。
本本
acer 4745g i5-430 4G ATI5650 1G 独显 500G硬盘
台台
赛扬coppermine 1.0GHz 160MB内存 集成显声卡 网卡一块。
archlinux+xfce无压力
cjs0722
帖子: 33
注册时间: 2011-03-12 17:13
送出感谢: 0
接收感谢: 0

Re: ubuntu中gcc无法编译程序-----急急急急急急急急急急急急

#14

帖子 cjs0722 » 2011-03-14 1:03

return 0;
回复

回到 “C/C++/Java”