学习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. springboot实战(汪云飞)学习-1-1

    java EE开发的颠覆者 spring boot 实战 随书学习-1 1.学习案例都是maven项目,首先要在eclipse 中配置 maven,主要修改maven的配置文件:配置文件下载链接: h ...

  2. JS中字符串的常见属性及方法

    1.属性 1.1.length var txt = "abc 123"; console.log(txt.length); 2.方法 2.1.返回字符位置(indexOf()) 该 ...

  3. java 序列化机制

    package stream; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io ...

  4. AcWing 312. 乌龟棋 (简单DP)打卡

    题目:https://www.acwing.com/problem/content/description/314/ 题意:有一段路,每个格子都有个价值,然后有m张卡牌,四种类型,走1,2,3,4步, ...

  5. Alex and Number

    Alex and Number 时间限制: 1 Sec  内存限制: 128 MB提交: 69  解决: 12[提交][状态] 题目描述 Alex love Number theory. Today ...

  6. vue将页面导出成pdf

    npm i jspdf-html2canvas prinOut(){ // 导出pdf let page = document.querySelector('.app-main'); // page ...

  7. python中的__init__

    __init__ __init__中__表示系统默认命名,init是初始化的意思.由于类可以起到模板的作用,因此,可以在创建实例的时候,把一些我们认为必须绑定的属性强制填写进去.以学生类为例,通过定义 ...

  8. LINUX shell脚本相关

    调试脚本 测试脚本语法:bash -n file.sh 查看脚本每一步执行情况:bash -x file.sh   位置变量:$1,$2,... 特殊变量:           %?:最后一个命令的执 ...

  9. Prometheus 安装与配置

    下载Prometheus https://prometheus.io/download/ wget https://github.com/prometheus/prometheus/releases/ ...

  10. python 使用[[v]*n]*m遇到的问题

    需求:想通过python生成m行n列的矩阵 方式1:(有问题) data = [[0]*3]*4 #4行3列 data 输出 [[0, 0, 0], [0, 0, 0], [0, 0, 0], [0, ...