Unix Network Programming Volume 1 Compile issue solution for the 2nd and 3rd edition

Unix Network Programming
Volume 1: The Sockets Networking API.
Compile issue solution for the 2nd and 3rd edition

Firstly please read the README and follow up.

cd unpv13e
./configure

cd lib
make
gcc -g -O2 -D_REENTRANT -Wall   -c -o connect_nonb.o connect_nonb.c
In file included from connect_nonb.c:1:
unp.h:114: redefinition of `struct in_pktinfo'
make: *** [connect_nonb.o] Error 1
Note: (only for 2nd edition, ok for 3rd edition)
Please comment the defination of `struct in_pktinfo' in unp.h file.

cd ../libfree
make
inet_ntop.c:61: error: argument 'size' doesn't match prototype
/usr/include/arpa/inet.h:153: error: prototype declaration
Note:
inet_ntop.c line 61: size_t size -> socklen_t size

cd ../libgai
make
Note: (the same issue as above for function: getnameinfo)
size_t size -> socklen_t size

cd ../libroute
make
Note: (only for system supports 4.4BSD, so no need on other system)
many build errors, please search carldebug
unproute.h
//add next define
#define RTAX_MAX 1024
unp.h
get_rtaddrs.c
get_rtaddrs.c: In function ‘get_rtaddrs’:
get_rtaddrs.c:24: error: ‘struct sockaddr’ has no member named ‘sa_len’
get_rtaddrs.c commet the memeber sa_len

cd ioctl
make
prmac.c:2:24: error: net/if_arp.h: No such file or directory
get file if_arp.h from intenet and copy to /usr/include/net

cd nonblock
make
make: *** No rule to make target `tcpservselect02', needed by `all'.  Stop.
Note: (Makefile typo issue)
PROGS = daytimetcpcli tcpcli01 tcpcli02 tcpcli03 tcpcli04 tcpservselect02 web
->
PROGS = daytimetcpcli tcpcli01 tcpcli02 tcpcli03 tcpcli04 tcpservselect03 web

cd unixdomain
make
daytimetcpsrv2.c:30: error: ‘MSG_EOR’ undeclared (first use in this function)
Note: add next define
#define MSG_EOR 0x00008

sys/ucred.h undefine
/usr/include/sys/ucred.h:73:30: error: sys/appleapiopts.h: No such file or directory

hostent3.o: In function `pr_ipv4':
/home/shexiang/unpv13e/names/hostent3.c:52: undefined reference to `_Inet_ntoa'
/home/shexiang/unpv13e/names/hostent3.c:54: undefined reference to `_gethostbyaddr_r'
Note: typo
Inet_ntoa -> inet_ntoa
add next in hostent3.c
#ifdef REENTRANT

netent.o: In function `main':
/home/shexiang/unpv13e/names/netent.c:11: undefined reference to `_getnetbyname'
It's bsd function


cd advio
make
dgechoaddr.o: In function `dg_echo':
/home/shexiang/unpv13e/advio/dgechoaddr.c:38: undefined reference to `_If_indextoname'
collect2: ld returned 1 exit status
Note: (typo issue)
If_indextoname -> if_indextoname

register.c:2:25: error: net/pfkeyv2.h: No such file or directory
Note: (search internet, and copy to net dir)
/usr/include/net/pfkeyv2.h


cd ../intro
make
...
/root/unpv12e/intro/daytimetcpsrvv6.c:18: undefined reference to `ipv6addr_any'
daytimetcpsrvv6.o(.text+0x3d):/root/unpv12e/intro/daytimetcpsrvv6.c:18: undefined reference to `ipv6addr_any'
daytimetcpsrvv6.o(.text+0x48):/root/unpv12e/intro/daytimetcpsrvv6.c:18: undefined reference to `ipv6addr_any'
daytimetcpsrvv6.o(.text+0x56):/root/unpv12e/intro/daytimetcpsrvv6.c:18: undefined reference to `ipv6addr_any
collect2: ld returned 1 exit status
make: *** [daytimetcpsrvv6] Error
Note:
daytimetcpsrvv6.c line 18: extern struct in6_addr ipv6addr_any;
-> struct in6_addr ipv6addr_any;

./daytimetcpsrv &
./daytimetcpcli 127.0.0.1
Then it's ok if it works.

猜你喜欢

转载自blog.csdn.net/carlshen/article/details/6312624