[英]Can't build source code for “Unix Network Programming: Interprocess Communication”
I'm using Linux Mint 13 and I am studying the book "Unix Network Programming: Interprocess Communication". 我正在使用Linux Mint 13,正在学习《 Unix网络编程:进程间通信》一书。 I downloaded the source code of the book - http://www.kohala.com/start/unpv22e/unpv22e.html - and followed the instructions.
我下载了该书的源代码-http: //www.kohala.com/start/unpv22e/unpv22e.html-并按照说明进行了操作。
First, I ran ./configure in the base directory 首先,我在基本目录中运行了./configure
Then, I went into the lib directory and ran make. 然后,我进入lib目录并运行make。 This gives the following error -
这给出了以下错误-
gcc -c "/home/linux/Code/c/unix_network_programming/main.c" -g -o ./Debug/main.o "-I." "-I."
In file included from /usr/lib/gcc/i686-linux-gnu/4.6/include/stdint.h:3:0,
from /usr/include/netinet/in.h:24,
from /usr/include/rpc/types.h:91,
from /usr/include/rpc/rpc.h:38,
from /home/linux/Code/c/unix_network_programming/unpipc.h:115,
from /home/linux/Code/c/unix_network_programming/main.c:2:
/usr/include/stdint.h:49:24: error: duplicate ‘unsigned’
/usr/include/stdint.h:49:24: error: two or more data types in declaration specifiers
/usr/include/stdint.h:50:28: error: duplicate ‘unsigned’
/usr/include/stdint.h:50:28: error: duplicate ‘short’
/usr/include/stdint.h:52:23: error: duplicate ‘unsigned’
/usr/include/stdint.h:52:23: error: two or more data types in declaration specifiers
Here's the file that is giving the error - 这是出现错误的文件-
#ifndef _GCC_WRAP_STDINT_H
#if __STDC_HOSTED__
# include_next <stdint.h>
#else
# include "stdint-gcc.h"
#endif
#define _GCC_WRAP_STDINT_H
#endif
Any ideas on how to fix this error as I have very little C experience? 关于C的经验很少,您如何解决此错误的任何想法?
Apply the following, mildly nasty patch: 应用以下轻微讨厌的补丁:
diff -U 3 ./aclocal.m4 ./aclocal.m4
--- ./aclocal.m4 1997-10-10 22:45:46.000000000 +0100
+++ ./aclocal.m4 2013-03-25 17:35:22.287397177 +0000
@@ -31,6 +31,7 @@
AC_TRY_COMPILE(
[
#include "confdefs.h" /* the header built by configure so far */
+#include <stdint.h>
#ifdef HAVE_SYS_TYPES_H
# include <sys/types.h>
#endif
diff -U 3 ../unpv22e/config.h.in ./config.h.in
--- ./config.h.in 1998-06-10 18:26:41.000000000 +0100
+++ ./config.h.in 2013-03-25 17:42:18.788139903 +0000
@@ -2,6 +2,7 @@
#undef CPU_VENDOR_OS
/* *INDENT-OFF* */
+#undef HAVE_STDINT_H
#undef HAVE_DOOR_H /* <door.h> */
#undef HAVE_MQUEUE_H /* <mqueue.h> */
#undef HAVE_POLL_H /* <poll.h> */
@@ -49,6 +50,9 @@
#undef HAVE_DEV_ZERO
/* Define the following to the appropriate datatype, if necessary */
+#ifdef HAVE_STDINT_H
+#include <stdint.h>
+#endif
#undef int8_t /* <sys/types.h> */
#undef int16_t /* <sys/types.h> */
#undef int32_t /* <sys/types.h> */
diff -U 3 ../unpv22e/configure.in ./configure.in
--- ./configure.in 1998-06-06 22:42:29.000000000 +0100
+++ ./configure.in 2013-03-25 17:38:14.555324559 +0000
@@ -105,7 +105,7 @@
dnl but used in "lib/wrapunix.c".
dnl
AC_HEADER_STDC
-AC_CHECK_HEADERS(sys/types.h sys/time.h time.h errno.h fcntl.h limits.h signal.h stdio.h stdlib.h string.h sys/stat.h unistd.h sys/wait.h sys/ipc.h sys/msg.h sys/sem.h sys/shm.h mqueue.h semaphore.h sys/mman.h sys/select.h poll.h stropts.h strings.h sys/ioctl.h sys/filio.h pthread.h door.h rpc/rpc.h sys/sysctl.h)
+AC_CHECK_HEADERS(stdint.h sys/types.h sys/time.h time.h errno.h fcntl.h limits.h signal.h stdio.h stdlib.h string.h sys/stat.h unistd.h sys/wait.h sys/ipc.h sys/msg.h sys/sem.h sys/shm.h mqueue.h semaphore.h sys/mman.h sys/select.h poll.h stropts.h strings.h sys/ioctl.h sys/filio.h pthread.h door.h rpc/rpc.h sys/sysctl.h)
dnl ##################################################################
dnl Checks for typedefs.
Then run autoconf (use autoconf2.13 rather than a newer version), delete config.cache, and try again. 然后运行autoconf(使用autoconf2.13而不是较新的版本),删除config.cache,然后重试。
Just comment out these lines in config.h (execute ./configure
first): 只需在config.h中注释掉这些行(首先执行
./configure
):
#define uint8_t unsigned char /* <sys/types.h> */
#define uint16_t unsigned short /* <sys/types.h> */
#define uint32_t unsigned int /* <sys/types.h> */
It works for me:). 这个对我有用:)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.