unix环境高级编程里的程序如何编译?

系统安装、升级讨论
版面规则
我们都知道新人的确很菜,也喜欢抱怨,并且带有浓厚的Windows习惯,但既然在这里询问,我们就应该有责任帮助他们解决问题,而不是直接泼冷水、简单的否定或发表对解决问题没有任何帮助的帖子。乐于分享,以人为本,这正是Ubuntu的精神所在。
回复
头像
widon1104
帖子: 839
注册时间: 2008-07-17 10:55

unix环境高级编程里的程序如何编译?

#1

帖子 widon1104 » 2008-11-01 20:14

#include"ourhdr.h"
int main()
{
printf("hello world from process ID %d\n",getpid());
exit(0);
}
widon@widon-laptop:~$ g++ -Wall id.cpp -o id
id.cpp:1:19: error: ourhdr.h: No such file or directory
id.cpp: In function ‘int main()’:
id.cpp:4: error: ‘getpid’ was not declared in this scope
id.cpp:4: error: ‘printf’ was not declared in this scope
id.cpp:5: error: ‘exit’ was not declared in this scope
从书上抄的
一个相当简单的程序都通不过。。
唐僧精神
头像
xhy
帖子: 3916
注册时间: 2005-12-28 1:16
系统: Ubuntu 12.10 X64
来自: 火星

Re: unix环境高级编程里的程序如何编译?

#2

帖子 xhy » 2008-11-01 20:38

先学会C语言再看apue比较好 没有基础是不行的
目前负债150多万
leeyee
帖子: 723
注册时间: 2006-04-11 9:01

Re: unix环境高级编程里的程序如何编译?

#3

帖子 leeyee » 2008-11-01 20:42

widon1104 写了: id.cpp:1:19: error: ourhdr.h: No such file or directory
I would love to change the world, but they won't give me the source code.
http://hi.baidu.com/wienerlee
bruce1914
帖子: 39
注册时间: 2008-10-27 1:43

Re: unix环境高级编程里的程序如何编译?

#4

帖子 bruce1914 » 2008-11-01 22:52

在书前面应该有写了一个文件,名字叫ourhdr.h, 你把它找出来写了放在当前目录
xeoc
帖子: 1994
注册时间: 2007-05-06 10:12

Re: unix环境高级编程里的程序如何编译?

#5

帖子 xeoc » 2008-11-01 22:59

xhy 写了:先学会C语言再看apue比较好 没有基础是不行的
恩,买了好久,还不敢弄,下学期吧...
头像
widon1104
帖子: 839
注册时间: 2008-07-17 10:55

Re: unix环境高级编程里的程序如何编译?

#6

帖子 widon1104 » 2008-11-02 0:49

在附件里面找到了ourhdr.h
回复