1 1. 编译原书所带例子: 2 unpv22e.tar.gz 下载地址:http://www.kohala.com/start/unpv22e/unpv22e.tar.gz 3 2. 解压: 4 $tar -zxvf unpv22e.tar.gz 5 3. 编译: 6 $cd unpv22e 7 $ ./configure 8 $ cd lib 9 $ make10 gcc -g -O2 -D_REENTRANT -Wall -D_POSIX_PTHREAD_SEMANTICS -c -o daemon_inetd.o daemon_inetd.c11 In file included from /usr/include/netinet/in.h:23,12 from /usr/include/rpc/types.h:90,13 from /usr/include/rpc/rpc.h:41,14 from unpipc.h:115,15 from daemon_inetd.c:1:16 /usr/include/stdint.h:49: 错误:重复的 'unsigned'17 /usr/include/stdint.h:49: 错误:声明指定了两个以上的数据类型18 /usr/include/stdint.h:50: 错误:重复的 'unsigned'19 /usr/include/stdint.h:50: 错误:重复的 'short'20 /usr/include/stdint.h:52: 错误:重复的 'unsigned'21 /usr/include/stdint.h:52: 错误:声明指定了两个以上的数据类型22 make: *** [daemon_inetd.o] 错误 123 这时需要修改unpipc.h第115行。unpipc.h中把115内容注释掉。再次编译。24 $ make25 gcc -g -O2 -D_REENTRANT -Wall -D_POSIX_PTHREAD_SEMANTICS -c -o daemon_inetd.o daemon_inetd.c26 In file included from daemon_inetd.c:1:27 unpipc.h:479: 错误:expected '=', ',', ';', 'asm' or '__attribute__' before '*' token28 unpipc.h:480: 错误:expected ')' before '*' token29 make: *** [daemon_inetd.o] 错误 130 再次出现错误,把unpipc.h中第479,480行注释掉。再次编译。31 $ make32 ...33 gcc -g -O2 -D_REENTRANT -Wall -D_POSIX_PTHREAD_SEMANTICS -c -o wrapsunrpc.o wrapsunrpc.c34 wrapsunrpc.c:3: 错误:expected '=', ',', ';', 'asm' or '__attribute__' before '*' token35 wrapsunrpc.c:16: 错误:expected ')' before '*' token36 make: *** [wrapsunrpc.o] 错误 137 这时还会出现上面的错误,这时需要修改unpv22e/Make.defines中的LIB_OBJS的".o"文件,删除"wrapsunrpc.o"。38 再次编译。39 $ make40 --这次应该没有问题了。
参考地址 http://blog.chinaunix.net/uid-27164517-id-3320677.html
下载的源码有些头文件没有,不过在lib里面按照上面修改之后基本能跑起来例子程序。