最近在看《UNIX网络编程-第二版-卷2:进程间通讯》,下载了源码,在SLES SP4 32bit 无法编译,需要做些修改如下
1 下载源码:
W. Richard Stevens的主页:http://www.kohala.com/start/
| 1
 | wget http://www.kohala.com/start/unpv22e/unpv22e.tar.gz -P /usr/local/src
 | 
2 解压
| 1
 | tar xvf /usr/local/src/unpv22e.tar.gz -C /root/bin
 | 
3 编译库文件,及修改头文件
| 12
 
 | cd /root/bin/unpv22e/./configure
 
 | 
3.1 修改生成config.h文件,注释以下几行
3.2 添加MSG_R和MSG_W定义
| 12
 3
 4
 
 | vi config.h67 typedef unsigned long ulong_t;
 68 #define MSG_R 0400
 69 #define MSG_W 0200
 
 | 
3.3 添加_GNU_SOURCE定义
| 12
 
 | vi config.h#define _GNU_SOURCE
 
 | 
3.4 编译warpunix.c,使用mkstemp函数替换mktemp函数
| 12
 3
 4
 5
 6
 7
 
 | cd lib181 void
 182 Mktemp(char *template)
 183 {
 184 if (mkstemp(template) == NULL || template[0] == 0)
 185 err_quit("mktemp error");
 186 }
 
 | 
3.5 编译生成libunpipc.a
4 构建自己的编写代码的目录
| 12
 3
 
 | mkdir -p /root/bin/unpv2cd -
 cp /root/bin/unpv22e/libunpipc.a /root/bin/unpv22e/config.h /root/bin/unpv22e/Make.defines .
 
 | 
5 编译各个目录自己的文件
复制各个子目录下得*.h头文件和Makfile文件,然后执行
| 12
 
 | cp /root/bin/unpv22e/dir/*.h /root/bin/unpv22e/dir/Makefile /root/bin/unpv2make filename
 
 | 
即可编译各个子目录下的代码