Unix网络编程 卷2:进程间通信(linux环境下源代码使用)

1. 下载源码,W. Richard Stevens的主页:http://www.kohala.com/start/
wget http://www.kohala.com/start/unpv22e/unpv22e.tar.gz -P /usr/local/src 
2. 解压
tar xvf /usr/local/src/unpv22e.tar.gz -C /root/bin 
3. 编译库文件
cd /root/bin/unpv22e/  
./configure 
编辑生成config.h文件,注释以下几行
vi config.h  
56 // #define uint8_t unsigned char  
57 // #define uint16_t unsigned short  
58 // #define uint32_t unsigned int  
添加MSG_R和MSG_W定义
vi config.h  
66 // add by jcq  
67 typedef unsigned long ulong_t;  
68 #define MSG_R 0400  
69 #define MSG_W 0200 
添加_GNU_SOURCE定义
vi config.h  
#define _GNU_SOURCE 
在unpv22e/lib目录下找到文件warpunix.c,使用mkstemp函数替换mktemp函数,然后编译所有lib下将会用到的库文件
181 void  
182 Mktemp(char *template)  
183 {  
184 if (mkstemp(template) == NULL || template[0] == 0)  
185 err_quit("mktemp error");  
186 } 
 
cd lib  
make 
此时会得到../libunpipc.a文件

4. 构建自己的编写代码的目录
mkdir -p /root/bin/unpv2  
cd -  
cp /root/bin/unpv22e/libunpipc.a /root/bin/unpv22e/config.h /root/bin/unpv22e/Make.defines . 

5. 编译各个目录自己的文件
复制各个子目录下得*.h头文件和Makfile文件,然后执行
cp /root/bin/unpv22e/dir/*.h /root/bin/unpv22e/dir/Makefile /root/bin/unpv2
make filename 
即可编译各个子目录下的代码
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值