版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/gc348342215/article/details/77714214
下载unp中的源代码:
切换到解压后的目录 unpv13e,先查看下 README,依次执行:
./configure
cd lib
make
cd ../libfree
make
此处报错:
inet_ntop.c:56:1: error: conflicting types for ‘inet_ntop’
inet_ntop(af, src, dst, size)
^
/usr/include/arpa/inet.h:77:13: note: previous declaration is here
const char inet_ntop(int, const void , char , socklen_t);
^
1 error generated.
make: ** [inet_ntop.o] Error 1
提示函数inet_ntop
重复声明了,其实是 头文件重复包含了。
解决方法:
找到inet_ntop.c
文件把#include <arpa/inet.h>
这行注释掉,重新make即可成功!
安装 unp.h 文件及其对应的静态链接库 libunp.a 到 系统目录
cd .. // 回到主目录
// 修改 unp.h
vim ./lib/unp.h // 修改 #include "../config.h" 为 #include "config.h"
// 拷贝头文件
sudo cp ./config.h /usr/local/include
sudo cp ./lib/unp.h /usr/local/include
// 拷贝库文件
sudo cp ./libunp.a /usr/local/lib