学习unp网络编程,树上的例子均存在#include "unp.h",故需要对环境进行配置。

1. 到资源页下载unpv13e

2. 解压并将unpv13e 移动到相应的文件夹下

3. 编译

 >$ cd unpv13e
>~unpv13e/$ ./configure >~unpv13e/$ cd lib
>~unpv13e/lib/$ make >~unpv13e/lib/$ cd ../libfree
>~unpv13e/libfree/$ make

如若出现以下问题:

 gcc -I../lib -g -O2 -D_REENTRANT -Wall   -c -o inet_ntop.o inet_ntop.c
inet_ntop.c: In function ‘inet_ntop’:
inet_ntop.c::: error: argument ‘size’ doesn’t match prototype
size_t size;
^
In file included from inet_ntop.c:::
/usr/include/arpa/inet.h::: error: prototype declaration
extern const char *inet_ntop (int __af, const void *__restrict __cp,
^
make: *** [inet_ntop.o] Error

则需要:

 >~unpv13e/libfree/$ vim inet_ntop.c  //将第60行的 size_t size 改成 socklen_t size;
>~unpv13e/libfree/$ make // 改变完后重新make
>~unpv13e/libfree/$ cd ../libgai
>~unpv13e/libgai/$ make //以下只是warning, 乎略之
/usr/include/arpa/inet.h: In function ‘inet_ntop’:
inet_ntop.c::: warning: ‘best.len’ may be used uninitialized in this function [-Wmaybe-uninitialized]
if (best.base == - || cur.len > best.len)
^
inet_ntop.c::: note: ‘best.len’ was declared here
struct { int base, len; } best, cur;
^
gcc -I../lib -g -O2 -D_REENTRANT -Wall -c -o inet_pton.o inet_pton.c
ar rv ../libunp.a in_cksum.o inet_ntop.o inet_pton.o
a - in_cksum.o
a - inet_ntop.o
a - inet_pton.o
ranlib ../libunp.a

至此,编译成功生成静态库libunp.a

4. 将生成的libunp.a复制到/usr/lib下

 >~unpv13e/libgai/$ cd ..
>~unpv13e/$ sudo cp libunp.a /usr/lib

5. 修改unpv13e/lib/unp.h并复制

 >~unpv13e/$ vim lib/unp.h  // 将#include "../config.h" 改成 #include "config.h"
>~unpv13e/$ sudo cp lib/unp.h /usr/include
>~unpv13e/$ sudo cp config.h /usr/include

6. 编译例子

 >~unpv13e/$  cd intro
>~unpv13e/$ gcc daytimetcpcli.c -o cli -lunp

编译成功则大功告成。

【unp】unix网络编程卷1-->环境搭建(ubuntu14.04)的更多相关文章

  1. UNIX网络编程卷1 - >环境搭建(ubuntu16.04)

      学习unp网络编程,树上的例子均存在#include“unp.h”,故需要对环境进行配置. 1.到资源页下载www.unpbook.com 2.解压并将unpv13e移动到相应的文件夹下 (因为我 ...

  2. 《UNIX网络编程 卷1》之"学习环境搭建"(CentOS 7)

    <UNIX网络编程 卷1>的源码可以从www.unpbook.com下载得到.解压之后的目录为unpv13e. 详细步骤 编译 进入unpv13e目录,按如下步骤编译: ./configu ...

  3. [转载] 读《UNIX网络编程 卷1:套接字联网API》

    原文: http://cstdlib.com/tech/2014/10/09/read-unix-network-programming-1/ 文章写的很清楚, 适合初学者 最近看了<UNIX网 ...

  4. UNIX网络编程 卷2:进程间通信

    这篇是计算机类的优质预售推荐>>>><UNIX网络编程 卷2:进程间通信(第2版)> UNIX和网络专家W. Richard Stevens的传世之作 编辑推荐 两 ...

  5. 《UNIX网络编程 卷1:套接字联网API》读书笔记(一):网络编程简介

    概述 要编写通过计算机网络通信的程序,首先要确定这些程序相互通信所用的协议.大多数网络是按照划分成客户和服务器来组织的.本章及后续章节的焦点是TCP/IP协议族,也可称为网际协议族.下图为客户与服务器 ...

  6. 《Unix网络编程卷1:套接字联网API》读书笔记

    第一部分:简介和TCP/IP 第1章:简介 第2章:传输层:TCP.UDP和SCTP TCP:传输控制协议,复杂.可靠.面向连接协议 UDP:用户数据报协议,简单.不可靠.无连接协议 SCTP:流控制 ...

  7. UNIX网络编程卷1 第一章 简介 读书笔记。

    基本没讲什么,一点点计算机网络发展史,一点点socket()简单介绍,最重要的是1.3节协议无关性. 协议无关性: 贯穿整本书的一个重要特性,他主要强调的是 socket是网络协议无关的编程接口. s ...

  8. UNIX网络编程卷1 时间获取程序server UDP 协议无关

    本文为senlie原创,转载请保留此地址:http://blog.csdn.net/zhengsenlie /** * UDP 协议无关 调用 getaddrinfo 和 udp_server **/ ...

  9. UNIX网络编程卷1 时间获取程序server TCP 协议相关性

    本文为senlie原创.转载请保留此地址:http://blog.csdn.net/zhengsenlie 最初代码:  这是一个简单的时间获取server程序.它和时间获取程序client一道工作. ...

随机推荐

  1. php mt_rand()函数 语法

    php mt_rand()函数 语法 mt_rand()函数怎么用? php mt_rand()函数表示从参数范围内得到一个随机数,语法是mt_rand(X,Y),从两个参数范围内得到一个随机数,随机 ...

  2. 10.17 linux 文件权限

    文件权限模拟练习 [root@wen ~]# groupadd incahome[root@wen ~]# usersdd oldboy -g incahome-bash: usersdd: comm ...

  3. flask-路转换器

    from flask import Flask, render_template from werkzeug.routing import BaseConverter # 配置regex路由转换器 # ...

  4. 用 Flask 来写个轻博客 (21) — 结合 reCAPTCHA 验证码实现用户注册与登录

    目录 目录 前文列表 扩展阅读 添加账户管理蓝图 新建控制器蓝图 新建表单 新建蓝图 main 的视图函数 新建模板 页面效果 前文列表 用 Flask 来写个轻博客 (1) - 创建项目 用 Fla ...

  5. 测开之路三十三:Flask实现扎金花游戏

    访问http://localhost:8888/game随机获取一张扑克牌.豹子(炸弹):三张点相同的牌.例:AAA.222.顺金(同花顺.色托):花色相同的顺子.例:黑桃456.红桃789.最大的顺 ...

  6. 动态创建类/ swizzle class

    动态创建类 Class subclass = objc_allocateClassPair(baseClass, subclassName, );//生成,指定父类 //添加方法,变量...一些操作 ...

  7. docker 提示 Drive has not been shared 错误

    Creating laradock_docker-in-docker_1 ... Creating laradock_docker-in-docker_1 ... error ERROR: for l ...

  8. selenium报错TypeError: 'FirefoxWebElement' object is not iterable

    报错原因element少了s定位一组元素的方法与定位单个元素的方法类似,唯一的区别是在单词element后面多了一个s表示复数. 改为 返回结果为

  9. Java数据访问对象模式

    数据访问对象模式或DAO模式用于将低级数据访问API或操作与高级业务服务分离. 以下是数据访问对象模式的参与者. 数据访问对象接口 - 此接口定义要对模型对象执行的标准操作. 数据访问对象具体类 - ...

  10. Java实验报告(四)&第六周学习总结

    班级 计科二班 学号 20188425 姓名 IM 完成时间2019/10/07 评分等级 一.实验目的 (1)掌握类的继承 (2)变量的继承和覆盖,方法的继承,重载和覆盖的实现: 二.实验的内容 ( ...