解压unpv13e.tar.gz后进入目录查看README,然后可以按照里面提示操作,不过会遇到问题。 第一步:在终端中进入upnv13e目录,然后执行代码:
$ ./configure 第二步:进入lib目录下执行make:
$ cd lib $ make 第三步:建立基础类库:
$ cd ../libfree # continue building the basic library $ make 会报错inet_ntop.c:61: error: argument ’size’ doesn’t match prototype /usr/include/arpa/inet.h:153: error: prototype declaration 解决方法:inet_ntop.c第60行 size_t size ->改成 socklen_t size 第四步:编译函数库:
$ cd ../libgai # the getaddrinfo() and getnameinfo() functions $ make 第五步:将生成的libunp.a静态库复制到/usr/lib/和/usr/lib64/中。
$ cd .. //回到unpv13e目录 $ sudo cp libunp.a /usr/lib $ sudo cp libunp.a /usr/lib64 第六步:修改unp.h并将其和config.h拷贝到/usr/include中,为了以后include方便
gedit lib/unp.h //将unp.h中#include "../config.h"修改为#include "config.h" $ sudo cp lib/unp.h /usr/include $ sudo cp config.h /usr/include 第七步:编译源代码
$ cd ./intro $ gcc daytimetcpcli.c -o daytimetcpcli -lunp参数-lunp表示链接libunp.a。 编写程序
以后编写完的程序按照第七中的代码编译就行。
|