关于网络编程遇到的小问题

来源:互联网 发布:温州网络推广公司 编辑:程序博客网 时间:2024/05/17 09:07

这一阵子正在学《unix网络编程:进程间通信》,编译时遇到点小问题,下面是找到的方案,在这里提下

(一)

1,download the source file unpv22e.tar.gz
2,tar -xf unpv22e.tar.gz,then all files will be extracted in to directory unpv22e
3,./configure,in most case this step won't enconter any problem
4,cd lib
5,make,if you enconter problem thus:

gcc -g -O2 -D_REENTRANT -Wall -D_POSIX_PTHREAD_SEMANTICS -c -o daemon_inetd.o daemon_inetd.c
In file included from /usr/include/netinet/in.h:23,
from /usr/include/rpc/types.h:90,
from /usr/include/rpc/rpc.h:41,
from unpipc.h:115,
from daemon_inetd.c:1:
/usr/include/stdint.h:49: 错误:重复的 ‘unsigned’
/usr/include/stdint.h:49: 错误:声明指定了两个以上的数据类型
/usr/include/stdint.h:50: 错误:重复的 ‘unsigned’
/usr/include/stdint.h:50: 错误:重复的 ‘short’
/usr/include/stdint.h:52: 错误:重复的 ‘unsigned’
/usr/include/stdint.h:52: 错误:声明指定了两个以上的数据类型
make: *** [daemon_inetd.o] 错误 1

now you just need comment line 56,57,58 in config.h,
save config.h file, then run make command sencond,
now it'ok!

我在Fedora下没有遇到这个问题,但Redhat下我以前就发现这个问题了,同时看到有人说ubuntu下也有这样的问题,我注释了这三行就避免了类型的重复的定义了

 

(二)

/tmp/cc0jERlh.o(.text+0x67): In function `eph_createmq':
: undefined reference to `mq_open'
/tmp/cc0jERlh.o(.text+0x9c): In function `eph_createmq':
: undefined reference to `mq_unlink'
collect2: ld returned 1 exit status

 

在编译的时候加上-lrt

如:cc -o ftok -lrt ftok.c error.c wrapunix.c