免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 2553 | 回复: 6
打印 上一主题 下一主题

Linux下gcc编译的问题? [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2005-12-14 17:14 |只看该作者 |倒序浏览
小弟刚刚接触Linux, 用gcc进行c编程, 在输入以下命令后:
# gcc -Wall /home/maintain/gcc/get_time.c -o get_time
/home/maintain/gcc/get_time.c:31:19: stdio.h: No such file or directory
/home/maintain/gcc/get_time.c:32:20: stdlib.h: No such file or directory
/home/maintain/gcc/get_time.c:33:20: string.h: No such file or directory
/home/maintain/gcc/get_time.c:34:18: time.h: No such file or directory

系统报错找不到系统头文件, 如stdio.h, stdlib.h, 我用的是网上下载的binary版本的gcc, 其问件目录如下:
[root@linuxroute gcc343]# ls -F
bin/  i686-pc-linux-gnu/  info/  libexec/  man/    tww-inst/
doc/  include/            lib/   license/  share/
请问如何设置编译器以便使其找到这些文件. 请赐教! 谢谢!

论坛徽章:
1
荣誉版主
日期:2011-11-23 16:44:17
2 [报告]
发表于 2005-12-14 17:19 |只看该作者
看看 /usr/include 下面有没有.

论坛徽章:
0
3 [报告]
发表于 2005-12-14 23:00 |只看该作者
--------------------------------------------------------------------------------

编译的时候出现以下错误
[root@localhost ex5]# gcc zombie.c -o zb.c
zombie.c:1:20: unistd.h: 没有那个文件或目录
zombie.c:2:20: stdlib.h: 没有那个文件或目录
zombie.c:3:19: stdio.h: 没有那个文件或目录
zombie.c:4:19: errno.h: 没有那个文件或目录
zombie.c:5:22: sys/wait.h: 没有那个文件或目录
zombie.c:6:23: sys/types.h: 没有那个文件或目录
zombie.c: In function `main':
zombie.c:45: error: `errno' undeclared (first use in this function)
zombie.c:45: error: (Each undeclared identifier is reported only once
zombie.c:45: error: for each function it appears in.)
源文件都没什么问题,估计是头文件没有,我已经安装了所有的开发工具
版本是redhat4企业版
库文件我不会装,linux方面只是个菜菜
希望能帮帮我,大家共同进步
谢谢了

论坛徽章:
0
4 [报告]
发表于 2005-12-14 23:02 |只看该作者
我的也是这样,帮你丁一下

论坛徽章:
0
5 [报告]
发表于 2005-12-15 07:51 |只看该作者
假设你的gcc343在/usr/local目录里,编译的时候加上

-I/usr/local/gcc343/include

论坛徽章:
0
6 [报告]
发表于 2006-01-01 18:23 |只看该作者

我加入了-I /usr/include/3.2.2仍然出错

我加入了-I /usr/include/3.2.2后仍然报错:

    cout  undeclared

我用的是vmvare ,不方便把错误拷贝下来,大致的内容是这样,程序如下:
#include <iostream>
int main(){
         cout << "Hello C++"<<endl;
}

我是个菜鸟,希望高手指点

论坛徽章:
0
7 [报告]
发表于 2006-01-01 18:36 |只看该作者

回复 6楼 91550 的帖子

using namespace std;
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP