分页: 1 / 1

[问题]gcc问题

发表于 : 2007-10-12 18:46
reaperman
安装gcc后 编辑hello.c文件完毕,在当前目录打开终端输入gcc hello.c -o hello
显示gcc: hello.c:No such file or directory
gcc: 没有输入文件

这是为什么?

发表于 : 2007-10-12 18:51
BigSnake.NET
No such file or directory
确认你的 hello.c 在当前目录下

发表于 : 2007-10-12 19:10
reaperman
恩刚才 确认了下 目录有点问题 改后 不再出现上述的错误,但出现
root@yzp-desktop:/media/hda1# gcc hello.c -o hello
hello.c: 在函数 ‘main’ 中:
hello.c:3: 警告: 隐式声明与内建函数 ‘printf’ 不兼容


我的hello.c是这么写的
int main(int argc,char **argv)
{
printf("Hello Linux\n");
}
这是什么问题呢

发表于 : 2007-10-12 19:32
xhy

代码: 全选

#include<stdio.h>

发表于 : 2007-10-12 19:33
BigSnake.NET

代码: 全选

$ sudo apt-get install build-essential 

发表于 : 2007-10-12 20:35
zccpop
我用gcc正常
用g++编译c++文件有问题》?
build-essential 也安装了

问题:

hello.cpp:1: 错误: 程序中有游离的 ‘\357’
hello.cpp:1: 错误: 程序中有游离的 ‘\274’
hello.cpp:1: 错误: 程序中有游离的 ‘\203’
hello.cpp:1: 错误: expected constructor, destructor, or type conversion before ‘<’ token
hello.cpp: In function ‘int main()’:
hello.cpp:7: 错误: ‘cout’ 在此作用域中尚未声明

发表于 : 2007-10-12 21:37
BigSnake.NET
zccpop 写了:我用gcc正常
用g++编译c++文件有问题》?
build-essential 也安装了

问题:

hello.cpp:1: 错误: 程序中有游离的 ‘\357’
hello.cpp:1: 错误: 程序中有游离的 ‘\274’
hello.cpp:1: 错误: 程序中有游离的 ‘\203’
hello.cpp:1: 错误: expected constructor, destructor, or type conversion before ‘<’ token
hello.cpp: In function ‘int main()’:
hello.cpp:7: 错误: ‘cout’ 在此作用域中尚未声明
1, 编程请用英文半角标点
2, using namespace std;

发表于 : 2007-10-12 21:50
zccpop
BigSnake.NET 写了:
zccpop 写了:我用gcc正常
用g++编译c++文件有问题》?
build-essential 也安装了

问题:

hello.cpp:1: 错误: 程序中有游离的 ‘\357’
hello.cpp:1: 错误: 程序中有游离的 ‘\274’
hello.cpp:1: 错误: 程序中有游离的 ‘\203’
hello.cpp:1: 错误: expected constructor, destructor, or type conversion before ‘<’ token
hello.cpp: In function ‘int main()’:
hello.cpp:7: 错误: ‘cout’ 在此作用域中尚未声明
1, 编程请用英文半角标点
2, using namespace std;
这两点我注意到的~

发表于 : 2007-10-12 23:57
zccpop
不好意思,让人汗颜。#这个符号用中文了。