温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

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

发布时间:2020-04-19 13:16:52 阅读:3788 作者:linuxjcq 栏目:系统运维
Unix服务器限时活动,0元免费领,库存有限,领完即止! 点击查看>>

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 /* <sys/types.h> */  57 // #define uint16_t unsigned short /* <sys/types.h> */  58 // #define uint32_t unsigned int /* <sys/types.h> */ 

添加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 

编译warpunix.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 -  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/unpv2make filename 

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

亿速云「云服务器」,即开即用、新一代英特尔至强铂金CPU、三副本存储NVMe SSD云盘,价格低至29元/月。点击查看>>

向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI

开发者交流群×