《UNIX网络编程 卷2》编译环境搭建

1. 下载源码

    W. Richard Stevens的主页:http://www.kohala.com/start/
    下载unpv22e.tar.gz到 /usr/local/src 目录

unpv22e.tar.gz可以到Linux公社资源站下载:

------------------------------------------分割线------------------------------------------

免费下载地址在 http://linux.linuxidc.com/

用户名与密码都是www.linuxidc.com

具体下载目录在 /2017年资料/2月/9日/ UNIX网络编程 卷2 源代码环境搭建/

下载方法见 http://www.linuxidc.com/Linux/2013-07/87684.htm

------------------------------------------分割线------------------------------------------

2. 解压

    tar xvf /usr/local/src/unpv22e.tar.gz -C /root/bin

    备注:一定要在/root/bin文件夹下,未尝试不在这个文件夹下,在第4步会报错。无法生成/libunpipc.a文件
3. 编译库文件
 
    cd /root/bin/unpv22e/  //备注:可能需要在root。不然权限不够

    ./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 
    65 // add by jcq 
    66 typedef unsigned long ulong_t;  //备注:此处,有的在前面加了#define ,我没有加,丧可以编译的。
    67 #define MSG_R 0400 
    68 #define MSG_W 0200
 

    添加_GNU_SOURCE定义
    vi config.h 
 
    #define _GNU_SOURCE


    在unpv22e/lib目录下找到文件wrapunix.c------------网上把这个文件名字全部都搞错了

    编译wrapunix.c,使用mkstemp函数替换mktemp函数
 
    cd lib 

    181 void 

    182 Mktemp(char *template) 

    183 { 

    184 if (mkstemp(template) == NULL || template[0] == 0) 

    185 err_quit("mktemp error"); 

    186 }

 

    编译生成libunpipc.a
    cd lib 
    make
4. 构建自己的编写代码的目录

    mkdir -p /root/bin/unpv2 

    cd -  //备注:这边最好 cd unpv2,不然下一步报错
    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

    即可编译各个子目录下的代码


UNIX Network Programming Volume 2》(Unix网络编程2英文版,djvu格式,带绿色小巧的阅读器) 原书名: UNIX Network Programming Volume 2:Interprocess Communications 2nd ed. 原出版社: Prentice Hall/Pearson 作者: W.Richard Stevens preface part 1. introduction chapter 1. introduction 1.1 introduction 3 1.2 processes, threads, and the sharing of information 5 1.3 persistence of ipc objects 6 1.4 name spaces 7 1.5 effect of fork, exec, and exit on ipc objects 9 1.6 error handling: wrapper functions 11 1.7 unix standards 13 1.8 road map to ipc examples in the text 15 1.9 summary 16 chapter 2. posix ipc 2.1 introduction 19 2.2 ipc names 19 2.3 creating and opening ipc channels 22 2.4 ipc permissions 25 2.5 summary 26 .chapter 3. system v ipc 3.1 introduction 27 3.2 key_t keys and ftok function 28 3.3 ipc_perm structure 30 3.4 creating and opening ipc channels 30 3.5 ipc permissions 32 3.6 identifier reuse 34 3.7 ipcs and ipcrm programs 36 3.8 kernel limits 36 3.9 summary 38 part 2. message passing chapter 4. pipes and fifos 4.1 introduction 43 4.2 a simple client--server example 43 4.3 pipes 44 4.4 full-duplex pipes 50 4.5 popen and pc1ose functions 52 4.6 fifos 54 4.7 additional properties of pipes and fifos 58 4.8 one server, multiple clients 60 4.9 iterative versus concurrent servers 66 4.10 streams and messages 67 4.11 pipe and fifo limits 72 4.12 summary 73 chapter 5. posix message oueues 5.1 introduction 75 5.2 mq_open, mq_c1ose, and mq_un1ink functions 76 5.3 mq_getattr and mq_setattr functions 79 5.4 mq_send and mq_receive functions 82 5.5 message queue limits 86 5.6 mq_notify function 87 5.7 posix realtime signals 98 5.8 implementation using memory-mapped i/o 106 5.9 summary 126 chapter 6. system v message queues 6.1 introduction 129 6.2 msgget function 130 6.3 msgsnd function 131 6.4 msgrcv function 132 6.5 msgctl function 134 6.6 simple programs 135 6.7 client-server example 140 6.8 multiplexing messages 142 6.9 message queues w
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值