UNIX网络编程 卷2 源代码使用

来源:互联网 发布:windows nt是什么 编辑:程序博客网 时间:2024/05/18 18:43

转载自http://linuxjcq.blog.51cto.com/3042600/718200,作者:linuxjcq

作者(linuxjcq)声明:原创作品,允许转载,转载时请务必以超链接形式标明文章原始出处 、作者信息和本声明。否则将追究法律http://linuxjcq.blog.51cto.com/3042600/718200

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. 编译库文件

  1. cd /root/bin/unpv22e/
  2. ./configure

编辑生成config.h文件,注释以下几行

  1. vi config.h
  2. 56 // #define uint8_t unsigned char /* <sys/types.h> */
  3. 57 // #define uint16_t unsigned short /* <sys/types.h> */
  4. 58 // #define uint32_t unsigned int /* <sys/types.h> */

添加MSG_R和MSG_W定义

  1. vi config.h
  2. 66 // add by jcq
  3. 67 typedef unsigned long ulong_t;
  4. 68 #define MSG_R 0400
  5. 69 #define MSG_W 0200

添加_GNU_SOURCE定义

  1. vi config.h
  2. #define _GNU_SOURCE

编译warpunix.c,使用mkstemp函数替换mktemp函数

  1. cd lib
  2. 181 void
  3. 182 Mktemp(char *template)
  4. 183 {
  5. 184 if (mkstemp(template) == NULL || template[0] == 0)
  6. 185 err_quit("mktemp error");
  7. 186 }

编译生成libunpipc.a

  1. cd lib
  2. make

4. 构建自己的编写代码的目录

  1. mkdir -p /root/bin/unpv2
  2. cd -
  3. cp /root/bin/unpv22e/libunpipc.a /root/bin/unpv22e/config.h /root/bin/unpv22e/Make.defines .


5. 编译各个目录自己的文件

复制各个子目录下得*.h头文件和Makfile文件,然后执行

  1. cp /root/bin/unpv22e/dir/*.h /root/bin/unpv22e/dir/Makefile /root/bin/unpv2make filename

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

本文出自 “linuxjcq” 博客,请务必保留此出处http://linuxjcq.blog.51cto.com/3042600/718200

原创粉丝点击