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 encoded ded 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 abve 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)
Using build errors, please search carldebug
Unproute. h
// Add next define
# Define rtax_max1024
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 'Your 6addr _ any'
Daytimetcpsrvv6.o (. Text + 0x3d):/root/unpv12e/intro/daytimetcpsrvv6.c: 18: Undefined reference to 'Your 6addr _ any'
Daytimetcpsrvv6.o (. Text + 0x48):/root/unpv12e/intro/daytimetcpsrvv6.c: 18: Undefined reference to 'Your 6addr _ any'
Daytimetcpsrvv6.o (. Text + 0x56):/root/unpv12e/intro/daytimetcpsrvv6.c: 18: Undefined reference to 'Your 6addr _ Any
Collect2: LD returned 1 exit status
Make: *** [daytimetcpsrvv6] Error
Note:
Daytimetcpsrvv6.c line 18: extern struct in6_addr limit 6addr_any;
-> Struct in6_addr limit 6addr_any;
./Daytimetcpsrv &
./Daytimetcpcli 127.0.0.1
Then it's OK if it works.