1.下载代码:官方下载http://www.unpbook.com/src.html
2.安装依赖库:
sudo apt-get install libbsd-dev
3.解压并进入解压后的文件夹(我的是解压到/root/unpv13e)
tar -zxvf unpv13e.tar.gz -C /root/unpv13e
4.按照README中的指导步骤进行(其中很详细)
QUICK AND DIRTY
===============
Execute the following from the src/ directory:
./configure # try to figure out all implementation differences
cd lib # build the basic library that all programs need
make # use "gmake" everywhere on BSD/OS systems
cd ../libfree # continue building the basic library
make
cd ../libroute # only if your system supports 4.4BSD style routing sockets
make # only if your system supports 4.4BSD style routing sockets
cd ../libxti # only if your system supports XTI
make # only if your system supports XTI
cd ../intro # build and test a basic client program
make daytimetcpcli
./daytimetcpcli 127.0.0.1
If all that works, you're all set to start compiling individual programs.
Notice that all the source code assumes tabs every 4 columns, not 8.
5.复制头文件(unp.h)和动态链接库(libunp.a)
sudo cp ./lib/unp.h /usr/include/
sudo cp ./libunp.a /usr/local/lib/
sudo cp ./libunp.a /usr/lib/
6.注销重启
7.运行程序时后面加上链接库即可(即 -lunp)
eg. gcc -o daytimetcpcli daytimetcpcli.c -lunp