1.在http://www.apuebook.com下载源代码

2. 视图READ

root@ubuntu:/home/wl/mywork/apue.2e# cat -n README
1 Read the file called DISCLAIMER.
2
3 Some source changes needed to be made after the book went out for the first
4 printing. I forgot to make corresponding changes in the source tree on the
5 system used to develop the book. The changes are summarized below.
6
7 1. lib/recvfd.c and sockets/recvfd.c - needed sys/uio.h on Mac OS X
8 2. lib/sendfd.c and sockets/sendfd.c - needed sys/uio.h on Mac OS X
9 3. stdio/buf.c - added code for Mac OS X
10 4. threadctl/suspend.c - changed wait to waitloc to avoid symbol definition
11 clash on Solaris
12 5. include/apue.h - FreeBSD compiles work better if we rely on the default
13 system settings. Solaris needed a different XOPEN_SOURCE definition
14 and also a CMSG_LEN definition.
15
16 To build the source, edit the Make.defines.* file for your system and set
17 WKDIR to the pathname of the tree containing the source code. Then just
18 run "make". It should figure out the system type and build the source for
19 that platform automatically. If you are running on a system other than
20 FreeBSD, Linux, Mac OS X, or Solaris, you'll need to modify the makefiles
21 to include the settings for your system. Also, you'll probably need to
22 modify the source code to get it to build on a different operating system.
23 The example source was compiled and tested using FreeBSD 5.2.1, Linux 2.4.22,
24 Mac OS X 10.3, and Solaris 9.
25
26 For FAQs, updated source code, and the lost chapter, see http://www.apuebook.com.
27 Please direct questions, suggestions, and bug reports to sar@apuebook.com.
28
29 Steve Rago
30 May 30, 2005
root@ubuntu:/home/wl/mywork/apue.2e#

从第16行開始看到19行就能够了~~

3. 改动Make.defines.linux

# Common make definitions, customized for each platform

# Definitions required in all program directories to compile and link
# C programs using gcc. WKDIR=/home/wl/mywork/apue.2e
#WKDIR=/home/sar/apue.2e
CC=gcc
COMPILE.c=$(CC) $(CFLAGS) $(CPPFLAGS) -c
LINK.c=$(CC) $(CFLAGS) $(CPPFLAGS) $(LDDIR) $(LDFLAGS)
LDDIR=-L../lib
LDLIBS=../lib/libapue.a $(EXTRALIBS)
CFLAGS=-DLINUX -ansi -I$(WKDIR)/include -Wall -D_GNU_SOURCE $(EXTRA)
CPPFLAGS=-I/home/wl/mywork/apue.2e/include
# Our library that almost every program needs.
LIB=../libapue.a # Common temp files to delete from each directory.
TEMPFILES=core core.* *.o temp.* *.out typescript*
~

各位仅仅须要改动上面大字部分改为自己的路径就能够了~~~

4. 将apue.h和error.c两个文件copy到/usr/include下

5. 编辑apue.h

#vi apue.h

在最后一行 #endif /* _APUE_H */

前面加入一行 #include "error.c"。

6. 编译源文件

(以source\file文件夹为例)

#cd file

#cp linux.mk Makefile

#make

root@ubuntu:/home/wl/mywork/apue.2e/file# make
gcc -DLINUX -ansi -I/home/wl/mywork/apue.2e/include -Wall -D_GNU_SOURCE -I/home/wl/mywork/apue.2e/include -L../lib access.c ../lib/libapue.a -o access
gcc -DLINUX -ansi -I/home/wl/mywork/apue.2e/include -Wall -D_GNU_SOURCE -I/home/wl/mywork/apue.2e/include -L../lib cdpwd.c ../lib/libapue.a -o cdpwd
gcc -DLINUX -ansi -I/home/wl/mywork/apue.2e/include -Wall -D_GNU_SOURCE -I/home/wl/mywork/apue.2e/include -L../lib changemod.c ../lib/libapue.a -o changemod
gcc -DLINUX -ansi -I/home/wl/mywork/apue.2e/include -Wall -D_GNU_SOURCE -I/home/wl/mywork/apue.2e/include -L../lib devrdev.c ../lib/libapue.a -o devrdev
gcc -DLINUX -ansi -I/home/wl/mywork/apue.2e/include -Wall -D_GNU_SOURCE -I/home/wl/mywork/apue.2e/include -L../lib fileflags.c ../lib/libapue.a -o fileflags
gcc -DLINUX -ansi -I/home/wl/mywork/apue.2e/include -Wall -D_GNU_SOURCE -I/home/wl/mywork/apue.2e/include -L../lib filetype.c ../lib/libapue.a -o filetype
gcc -DLINUX -ansi -I/home/wl/mywork/apue.2e/include -Wall -D_GNU_SOURCE -I/home/wl/mywork/apue.2e/include -L../lib ftw4.c ../lib/libapue.a -o ftw4
gcc -DLINUX -ansi -I/home/wl/mywork/apue.2e/include -Wall -D_GNU_SOURCE -I/home/wl/mywork/apue.2e/include -L../lib hello.c ../lib/libapue.a -o hello
gcc -DLINUX -ansi -I/home/wl/mywork/apue.2e/include -Wall -D_GNU_SOURCE -I/home/wl/mywork/apue.2e/include -L../lib hole.c ../lib/libapue.a -o hole
gcc -DLINUX -ansi -I/home/wl/mywork/apue.2e/include -Wall -D_GNU_SOURCE -I/home/wl/mywork/apue.2e/include -L../lib longpath.c ../lib/libapue.a -o longpath
gcc -DLINUX -ansi -I/home/wl/mywork/apue.2e/include -Wall -D_GNU_SOURCE -I/home/wl/mywork/apue.2e/include -L../lib ls1.c ../lib/libapue.a -o ls1
gcc -DLINUX -ansi -I/home/wl/mywork/apue.2e/include -Wall -D_GNU_SOURCE -I/home/wl/mywork/apue.2e/include -L../lib mycd.c ../lib/libapue.a -o mycd
gcc -DLINUX -ansi -I/home/wl/mywork/apue.2e/include -Wall -D_GNU_SOURCE -I/home/wl/mywork/apue.2e/include -L../lib seek.c ../lib/libapue.a -o seek
gcc -DLINUX -ansi -I/home/wl/mywork/apue.2e/include -Wall -D_GNU_SOURCE -I/home/wl/mywork/apue.2e/include -L../lib testerror.c ../lib/libapue.a -o testerror
gcc -DLINUX -ansi -I/home/wl/mywork/apue.2e/include -Wall -D_GNU_SOURCE -I/home/wl/mywork/apue.2e/include -L../lib uidgid.c ../lib/libapue.a -o uidgid
gcc -DLINUX -ansi -I/home/wl/mywork/apue.2e/include -Wall -D_GNU_SOURCE -I/home/wl/mywork/apue.2e/include -L../lib umask.c ../lib/libapue.a -o umask
gcc -DLINUX -ansi -I/home/wl/mywork/apue.2e/include -Wall -D_GNU_SOURCE -I/home/wl/mywork/apue.2e/include -L../lib unlink.c ../lib/libapue.a -o unlink
gcc -DLINUX -ansi -I/home/wl/mywork/apue.2e/include -Wall -D_GNU_SOURCE -I/home/wl/mywork/apue.2e/include -L../lib zap.c ../lib/libapue.a -o zap
root@ubuntu:/home/wl/mywork/apue.2e/file#

编译成功

------------------------------------------------------------enjoy-------------------------------------------------------------------------------------

-----------------------------------------------------------the end-----------------------------------------------------------------------------------

版权声明:本文博客原创文章,博客,未经同意,不得转载。

《UNIX编程环境》的源代码的第二个版本Ubuntu下编的更多相关文章

  1. Unix NetWork Programming(unix环境编程)——环境搭建(解决unp.h等源码编译问题)

    此配置实例亲测成功,共勉,有问题大家留言. 环境:VMware 10 + unbuntu 14.04 为了unix进行网络编程,编程第一个unix程序时遇到的问题,不能包含unp.h文件,这个感觉和a ...

  2. 记录一次配置unix网络编程环境的过程和遇到的问题

    记录一次搭建unix网络编程环境过程中遇到的问题和总结 计算机环境虚拟机 linuxmint-18-xfce-64bit 1.打开unix网络编程.iso 把目录下的文件复制到某一目录,修改权限,可命 ...

  3. UNIX高级环境编程1

    UNIX高级环境编程1 故宫角楼是很多摄影爱好者常去的地方,夕阳余辉下的故宫角楼平静而安详. 首先,了解一下进程的基本概念,进程在内存中布局和内容. 此外,还需要知道运行时是如何为动态数据结构(如链表 ...

  4. unix网络编程环境搭建

    unix网络编程环境搭建 网络编程 环境 1.点击下载源代码 可以通过下列官网中的源代码目录下载最新代码: http://www.unpbook.com/src.html 2.解压文件 tar -xz ...

  5. Unix高级环境编程

    [07] Unix进程环境==================================1. 进程终止    atexit()函数注册终止处理程序.    exit()或return语句:    ...

  6. Unix/Linux环境C编程入门教程(32) 环境变量那些事儿

    1. getenv() putenv()setenv()函数介绍 getenv(取得环境变量内容) 相关函数 putenv,setenv,unsetenv 表头文件 #include<stdli ...

  7. UNIX高级环境编程(14)文件IO - O_DIRECT和O_SYNC详解 < 海棠花溪 >

    春天来了,除了工作学习,大家也要注意锻炼身体,多出去运动运动.  上周末在元大都遗址公园海棠花溪拍的海棠花.   进入正题. O_DIRECT和O_SYNC是系统调用open的flag参数.通过指定o ...

  8. UNIX环境编程初步认识——编程环境搭建

     前言 前期学习了Linux的一些基本知识后,在借助前期的学习的基础上想再初步认识一下操作系统的一些环境编程体系相关知识,当中环境的配置和搭建费了非常大的劲,须要一点点摸索和尝试,下边是环境搭建的 ...

  9. 学习linux/unix编程方法的建议(转)

    假设你是计算机科班出身,计算机系的基本课程如数据结构.操作系统.体系结构.编译原理.计算机网络你全修过 我想大概可以分为4个阶段,水平从低到高从安装使用=>linux常用命令=>linux ...

随机推荐

  1. 积累的VC编程小技巧之树操作

    1.如何在TreeList中加图标? [问题提出]  请问treeview控件和treectrl控件的用法有何不同呢?向如何imagelist控件中加图象呀?  [解决方法]  1)    HICON ...

  2. 百度地图new BMap.LocalCity() 问题

    <html> <head> <meta http-equiv="Content-Type" content="text/html; char ...

  3. 【ASP.NET Web API教程】4.3 ASP.NET Web API中的异常处理

    原文:[ASP.NET Web API教程]4.3 ASP.NET Web API中的异常处理 注:本文是[ASP.NET Web API系列教程]的一部分,如果您是第一次看本系列教程,请先看前面的内 ...

  4. UVa 11233 - Deli Deli

    题目:求所给单词的负数形式. 分析:模拟. 直接按章题意分情况求解就可以. 说明:按语法也能够(⊙_⊙). #include <iostream> #include <cstdlib ...

  5. Delphi透明组件开发(去掉自己的csOpaque,去掉父控件的WS_CLIPCHILDREN,增加WS_EX_TRANSPARENT,截获WM_ERASEBKGND,然后在WM_DRAWITEM里画) good

    透明的控件, 一般继承自TGraphicControl的(就是那些没有handle属性, 不能有focus的控件, 如image)都有Transparent属性. 对TWinControl类的控件, ...

  6. Redis 学习笔记五 经常使用php函数

    PHPRedis的安装在这里: http://blog.csdn.net/xundh/article/details/46288277 键值操作 $redis = new Redis(); $redi ...

  7. 如何理解java回电话

    同android中间Button的setOnClickListener这个回调案例: Button button = (Button)this.findViewById(R.id.button); b ...

  8. java定义和实现接口

    1.定义接口     使用interface来定义一个接口.接口定义同类的定义类似,也是分为接口的声明和接口体.当中接口体由常量定义和方法定义两部分组成.定义接口的基本格式例如以下: [修饰符] in ...

  9. SetDlgItemText控件运行错误

    SetDlgltem函数把一个WM_SETTEXT消息发送到指定的控件. 今天在测试一个小程序,发现使用SetDlgItemText控件编译没问题,但是运行就出错误. 语句为: time=CTime: ...

  10. thinkPHP 模板的使用技巧(十三)

    原文:thinkPHP 模板的使用技巧(十三) 模板的使用技巧:页面跳转 .模板包含.模板渲染.模板的继承 页面跳转 <a href='__URL__/index'>我要跳转到首页面,用这 ...