中国古代雕塑作品:UNIX网络编程 源代码 使用方法
来源:百度文库 编辑:中财网 时间:2024/05/09 12:39:12
1.编译《UNP》
http://www.unpbook.com/unpv13e.tar.gz
我们首先产生一个目录,以后自己的代码就敲在这个目录里。
mkdir /home/hehe/study/unp
仍然是下载到/home/hehe/download/,解压缩,进入目录
cd /home/hehe/download/unpv13e/
README 文件中说的很详细:
========================================
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
========================================
这里只编译lib下的文件,这样可以产生libunp.a,复制这个静态库到/usr/lib/和/usr/lib64/
如果提示:
unp.h:139: error: conflicting types for ‘socklen_t’
/usr/include/bits/socket.h:35: error: previous declaration of ‘socklen_t’ was here
需要注释掉当前目录中unp.h的第139行。
复制libunp.a到系统目录:
root@dan-laptop:/home/hehe/download/unpv13e/lib# cp ../libunp.a /usr/lib
root@dan-laptop:/home/hehe/download/unpv13e/lib# cp ../libunp.a /usr/lib64/
2.使用unp.h和libunp.a
如果直接复制unpv13e/lib/unp.h和config.h到/usr/include,那么在别的目录编译书上代码时,很可会得到类似下面的错误:
In file included from daytimetcpsrv1.c:1:
/usr/include/unp.h:227: error: redefinition of ‘struct sockaddr_storage’
In file included from daytimetcpsrv1.c:1:
/usr/include/unp.h:249:30: error: ../lib/addrinfo.h: No such file or directory
/usr/include/unp.h:263: error: redefinition of ‘struct timespec’
/usr/include/unp.h:363: error: conflicting types for ‘gai_strerror’
/usr/include/netdb.h:647: error: previous declaration of ‘gai_strerror’ was here
/usr/include/unp.h:367: error: conflicting types for ‘getnameinfo’
/usr/include/netdb.h:653: error: previous declaration of ‘getnameinfo’ was here
/usr/include/unp.h:371: error: conflicting types for ‘gethostname’
/usr/include/unistd.h:857: error: previous declaration of ‘gethostname’ was here
/usr/include/unp.h:387: error: conflicting types for ‘inet_ntop’
/usr/include/arpa/inet.h:65: error: previous declaration of ‘inet_ntop’ was here
/usr/include/unp.h:395: error: conflicting types for ‘pselect’
/usr/include/sys/select.h:121: error: previous declaration of ‘pselect’ was here
daytimetcpsrv1.c: In function ‘main’:
daytimetcpsrv1.c:9: error: ‘MAX_LINE’ undeclared (first use in this function)
daytimetcpsrv1.c:9: error: (Each undeclared identifier is reported only once
daytimetcpsrv1.c:9: error: for each function it appears in.)
dan@dan-laptop:~/study/unp/4$ rm -f /usr/include/unp.h
这是因为unp.h包含config.h使用的是#include "../config.h",而此时unp.h和config.h的位置关系发生了变化,只需改为#include "./config.h"即可
http://www.unpbook.com/unpv13e.tar.gz
我们首先产生一个目录,以后自己的代码就敲在这个目录里。
mkdir /home/hehe/study/unp
仍然是下载到/home/hehe/download/,解压缩,进入目录
cd /home/hehe/download/unpv13e/
README 文件中说的很详细:
========================================
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
========================================
这里只编译lib下的文件,这样可以产生libunp.a,复制这个静态库到/usr/lib/和/usr/lib64/
如果提示:
unp.h:139: error: conflicting types for ‘socklen_t’
/usr/include/bits/socket.h:35: error: previous declaration of ‘socklen_t’ was here
需要注释掉当前目录中unp.h的第139行。
复制libunp.a到系统目录:
root@dan-laptop:/home/hehe/download/unpv13e/lib# cp ../libunp.a /usr/lib
root@dan-laptop:/home/hehe/download/unpv13e/lib# cp ../libunp.a /usr/lib64/
2.使用unp.h和libunp.a
如果直接复制unpv13e/lib/unp.h和config.h到/usr/include,那么在别的目录编译书上代码时,很可会得到类似下面的错误:
In file included from daytimetcpsrv1.c:1:
/usr/include/unp.h:227: error: redefinition of ‘struct sockaddr_storage’
In file included from daytimetcpsrv1.c:1:
/usr/include/unp.h:249:30: error: ../lib/addrinfo.h: No such file or directory
/usr/include/unp.h:263: error: redefinition of ‘struct timespec’
/usr/include/unp.h:363: error: conflicting types for ‘gai_strerror’
/usr/include/netdb.h:647: error: previous declaration of ‘gai_strerror’ was here
/usr/include/unp.h:367: error: conflicting types for ‘getnameinfo’
/usr/include/netdb.h:653: error: previous declaration of ‘getnameinfo’ was here
/usr/include/unp.h:371: error: conflicting types for ‘gethostname’
/usr/include/unistd.h:857: error: previous declaration of ‘gethostname’ was here
/usr/include/unp.h:387: error: conflicting types for ‘inet_ntop’
/usr/include/arpa/inet.h:65: error: previous declaration of ‘inet_ntop’ was here
/usr/include/unp.h:395: error: conflicting types for ‘pselect’
/usr/include/sys/select.h:121: error: previous declaration of ‘pselect’ was here
daytimetcpsrv1.c: In function ‘main’:
daytimetcpsrv1.c:9: error: ‘MAX_LINE’ undeclared (first use in this function)
daytimetcpsrv1.c:9: error: (Each undeclared identifier is reported only once
daytimetcpsrv1.c:9: error: for each function it appears in.)
dan@dan-laptop:~/study/unp/4$ rm -f /usr/include/unp.h
这是因为unp.h包含config.h使用的是#include "../config.h",而此时unp.h和config.h的位置关系发生了变化,只需改为#include "./config.h"即可
谁有《windows网络编程》配套源代码,求
俄罗斯方块编程源代码
那里有原始unix的源代码啊
UNIX的一道编程题
谁有《java网络编程实例》 这本书的源代码
哪儿有游戏编程源代码
VB编程如何写源代码
编程后如何加密源代码?
请教两个unix shell编程题
UNIX SHELL 编程什么书比较好
Unix下C编程方面的资料
请问如何学习UNIX下的编程
请问如何学习UNIX下的编程
学好UNIX编程,到底应该怎么做!
Unix Linux语言编程这几题怎么做
Unix Linux语言编程这几题怎么做
哪里有《莱昂氏UNIX源代码分析》的中文版 下载啊
请问unix的源代码是公开的吗?
哪里有免费的Unix源代码可以下载?
网络计数器的源代码是什么
高中VB编程的一些源代码
学编程是不是要多看源代码啊
编程语言→源代码(源程序)→程序
求ASP3.0高级编程的源代码