【unp】unix网络编程卷1-->环境搭建(ubuntu14.04)
学习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)的更多相关文章
- UNIX网络编程卷1 - >环境搭建(ubuntu16.04)
学习unp网络编程,树上的例子均存在#include“unp.h”,故需要对环境进行配置. 1.到资源页下载www.unpbook.com 2.解压并将unpv13e移动到相应的文件夹下 (因为我 ...
- 《UNIX网络编程 卷1》之"学习环境搭建"(CentOS 7)
<UNIX网络编程 卷1>的源码可以从www.unpbook.com下载得到.解压之后的目录为unpv13e. 详细步骤 编译 进入unpv13e目录,按如下步骤编译: ./configu ...
- [转载] 读《UNIX网络编程 卷1:套接字联网API》
原文: http://cstdlib.com/tech/2014/10/09/read-unix-network-programming-1/ 文章写的很清楚, 适合初学者 最近看了<UNIX网 ...
- UNIX网络编程 卷2:进程间通信
这篇是计算机类的优质预售推荐>>>><UNIX网络编程 卷2:进程间通信(第2版)> UNIX和网络专家W. Richard Stevens的传世之作 编辑推荐 两 ...
- 《UNIX网络编程 卷1:套接字联网API》读书笔记(一):网络编程简介
概述 要编写通过计算机网络通信的程序,首先要确定这些程序相互通信所用的协议.大多数网络是按照划分成客户和服务器来组织的.本章及后续章节的焦点是TCP/IP协议族,也可称为网际协议族.下图为客户与服务器 ...
- 《Unix网络编程卷1:套接字联网API》读书笔记
第一部分:简介和TCP/IP 第1章:简介 第2章:传输层:TCP.UDP和SCTP TCP:传输控制协议,复杂.可靠.面向连接协议 UDP:用户数据报协议,简单.不可靠.无连接协议 SCTP:流控制 ...
- UNIX网络编程卷1 第一章 简介 读书笔记。
基本没讲什么,一点点计算机网络发展史,一点点socket()简单介绍,最重要的是1.3节协议无关性. 协议无关性: 贯穿整本书的一个重要特性,他主要强调的是 socket是网络协议无关的编程接口. s ...
- UNIX网络编程卷1 时间获取程序server UDP 协议无关
本文为senlie原创,转载请保留此地址:http://blog.csdn.net/zhengsenlie /** * UDP 协议无关 调用 getaddrinfo 和 udp_server **/ ...
- UNIX网络编程卷1 时间获取程序server TCP 协议相关性
本文为senlie原创.转载请保留此地址:http://blog.csdn.net/zhengsenlie 最初代码: 这是一个简单的时间获取server程序.它和时间获取程序client一道工作. ...
随机推荐
- hdu 5120 Intersection (圆环面积相交->圆面积相交)
Problem Description Matt is a big fan of logo design. Recently he falls in love with logo made up by ...
- paper 167:GPU的使用Theano之tutorial
Theano之使用GPU 英文版本:http://deeplearning.net/software/theano/tutorial/using_gpu.html using the ...
- 安装maven之后,cmd提示mvn不是内部命令的解决办法
1.maven的安装教程 下载地址为:http://maven.apache.org/download.cgi 进入此页面之后 点击下载,然后解压,我把目录名改为maven,目录结构如下图所示 下面我 ...
- COALESCE 函数作用
用途. 将空值替换成其他值 返回第一个非空值. 任意一个不为空的值.比较有用.
- 抓包工具charles下载安装(MAC版)
什么是charles? charles是一个HTTP代理服务器,HTTP监视器,反转代理服务器,当浏览器连接Charles的代理访问互联网时,Charles可以监控浏览器发送和接收的所有数据.它允许一 ...
- Python笔记(六)_函数
函数一般是从第一行代码开始执行,结束于return语句.异常.或者函数所有语句执行完毕.一旦函数将控制权交还给调用者,就意味着全部结束.函数中做的所有工作以及保存在局部变量中的数据都将丢失.再次调用这 ...
- [题解]Yet Another Subarray Problem-DP 、思维(codeforces 1197D)
题目链接:https://codeforces.com/problemset/problem/1197/D 题意: 给你一个序列,求一个子序列 a[l]~a[r] 使得该子序列的 sum(l,r)-k ...
- git使用记录九:开发中临时加塞了紧急任务怎么处理
开发中临时加塞了紧急任务怎么处理 隐藏工作区域 git stash git status 查询隐藏的列表 git stash list 处理完bug,提交之后,再恢复隐藏的工作区域 git stash ...
- git使用记录四:.git分析
git使用记录四: .git 查看.git 目录下的文件 soaeon@DESKTOP-FUJJTHR MINGW64 /f/gitstudy/.git (GIT_DIR!) $ ls -al tot ...
- 【Python—windows 下 virtualEnv 使用】
用pip安装virtualenv pip3 install virtualenv 在相应的文件夹中创建一个独立的Python运行环境,命名为env. 之后会自动创建一个 env 文件夹,有: Incl ...