unix网络编程 环境搭建 环境配置
来源:互联网 发布:苹果电脑编写代码软件 编辑:程序博客网 时间:2024/06/06 04:44
转自:http://blog.csdn.net/zone_programming/article/details/51050726
遇到跟这篇博客一模一样的问题,但是搜索时并没有出现在首页,于是转载并重新起了个题目。
学习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:60:9: error: argument ‘size’ doesn’t match prototype
- size_t size;
- ^
- In file included from inet_ntop.c:27:0:
- /usr/include/arpa/inet.h:64:20: error: prototype declaration
- extern const char *inet_ntop (int __af, const void *__restrict __cp,
- ^
- make: *** [inet_ntop.o] Error 1
则需要:
- >~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:152:23: warning: ‘best.len’ may be used uninitialized in this function [-Wmaybe-uninitialized]
- if (best.base == -1 || cur.len > best.len)
- ^
- inet_ntop.c:123:28: 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
阅读全文
0 0
- unix网络编程 环境搭建 环境配置
- Unix网络编程环境搭建
- UNIX 网络编程环境配置
- Unix网络编程—环境搭建
- unix网络编程环境搭建及使用方法
- Unix网络编程之环境搭建
- linux clion unix网络编程环境搭建
- unix网络编程源代码环境搭建
- UNIX网络编程之一:代码环境搭建
- unix网络编程之环境配置
- UNIX网络编程编译环境配置方法
- UNIX网络编程之环境配置
- unix网络编程第三版环境配置
- unix网络编程第三版环境配置
- unix高级环境编程和网络编程环境配置
- unix网络编程环境
- unix网络编程环境
- unix网络编程环境
- 自定义view画圆,并且圆可以随意拖动
- Android关于TextureView理解及基本使用
- C++ 函数对象
- AUTOCAD的DWG图纸怎么转换成PDF文件
- Android studio使用JNI的的异常的处理(app:compileDebugNdk)
- unix网络编程 环境搭建 环境配置
- 这是 ApiDemo的文档
- 4.extern存储类练习。
- 安卓多线程模板
- Leetcode-4Sum
- 金蝶EAS,编辑界面EditUI必录校验,业务校验,单据头及分录必输校验
- Json对象和Json字符串的区别
- class.c 添加中文注释(1)
- centos 系 为网卡添加带vlan的子接口