LinuxSir.cn,穿越时空的Linuxsir!

 找回密码
 注册
搜索
热搜: shell linux mysql
查看: 1031|回复: 2

编译libdnet的问题

[复制链接]
发表于 2004-4-16 14:19:48 | 显示全部楼层 |阅读模式
libdnet     http://libdnet.sourceforge.net

在FC1上编译libdnet老报错,不知道怎么搞得,但是我在其他的机子上,分别是
redhat7.3和redhat7.1的OS都可以编译通过的

我make的方法及其机器的显示如下:

# ./configure
checking for a BSD compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking whether make sets ${MAKE}... yes
checking for working aclocal-1.4... found
checking for working autoconf... found
checking for working automake-1.4... found
checking for working autoheader... found
checking for working makeinfo... missing
checking build system type... i686-pc-linux-gnu
checking host system type... i686-pc-linux-gnu
checking for gcc... gcc
checking for C compiler default output... a.out
checking whether the C compiler works... yes
checking whether we are cross compiling... no
checking for executable suffix...
checking for object suffix... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for a BSD compatible install... /usr/bin/install -c
checking for ranlib... ranlib
checking for gethostbyname... yes
checking for socket... yes
checking for putmsg in -lstr... no
checking for open_mib in -lnm... no
checking for libcheck... no
checking how to run the C preprocessor... gcc -E
checking for ANSI C header files... yes
checking for fcntl.h... yes
checking for unistd.h... yes
checking for sys/bufmod.h... no
checking for sys/dlpi.h... no
checking for sys/dlpihdr.h... no
checking for sys/dlpi_ext.h... no
checking for sys/ioctl.h... yes
checking for sys/mib.h... no
checking for sys/ndd_var.h... no
checking for sys/socket.h... yes
checking for sys/sockio.h... no
checking for sys/sysctl.h... yes
checking for sys/time.h... yes
checking for net/bpf.h... yes
checking for net/if.h... yes
checking for net/if_arp.h... yes
checking for net/if_dl.h... no
checking for net/pfvar.h... no
checking for net/raw.h... no
checking for net/route.h... yes
checking for netinet/ip_fw.h... no
checking for linux/ip_fw.h... no
checking for linux/ip_fwchains.h... no
checking for linux/netfilter_ipv4/ipchains_core.h... yes
checking for ip_fil_compat.h... no
checking for netinet/ip_fil_compat.h... no
checking for ip_compat.h... no
checking for netinet/ip_compat.h... no
checking for ip_fil.h... no
checking for netinet/ip_fil.h... no
checking for hpsecurity.h... no
checking for gcc option to accept ANSI C... none needed
checking for an ANSI C-conforming const... yes
checking for inline... inline
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... (cached) yes
checking for pid_t... yes
checking for size_t... yes
checking for sockaddr_in6 struct in <netinet/in.h>... yes
checking for sa_len in sockaddr struct... no
checking for arp_dev in arpreq struct... yes
checking for rt_msghdr struct in <net/route.h>... no
checking whether gcc needs -traditional... no
checking for working memcmp... yes
checking for err... yes
checking for strlcat... no
checking for strlcpy... no
checking for Berkeley Packet Filter... no
checking for Linux proc filesystem... yes
checking for Linux PF_PACKET sockets... yes
checking for SNMP MIB2 STREAMS... no
checking for route(7) STREAMS... no
checking for arp(7) ioctls... yes
checking for raw IP sockets ip_{len,off} host byte ordering... no
checking for cooked raw IP sockets... no
configure: creating ./config.status
config.status: creating Makefile
config.status: creating dnet-config
config.status: creating include/Makefile
config.status: creating include/dnet/Makefile
config.status: creating man/Makefile
config.status: creating src/Makefile
config.status: creating test/Makefile
config.status: creating test/check/Makefile
config.status: creating test/dnet/Makefile
config.status: creating include/config.h

# make
Making all in include
make[1]: Entering directory `/root/libdnet-1.7/include'
make  all-recursive
make[2]: Entering directory `/root/libdnet-1.7/include'
Making all in dnet
make[3]: Entering directory `/root/libdnet-1.7/include/dnet'
make[3]: Nothing to be done for `all'.
make[3]: Leaving directory `/root/libdnet-1.7/include/dnet'
make[3]: Entering directory `/root/libdnet-1.7/include'
make[3]: Leaving directory `/root/libdnet-1.7/include'
make[2]: Leaving directory `/root/libdnet-1.7/include'
make[1]: Leaving directory `/root/libdnet-1.7/include'
Making all in man
make[1]: Entering directory `/root/libdnet-1.7/man'
make[1]: Nothing to be done for `all'.
make[1]: Leaving directory `/root/libdnet-1.7/man'
Making all in src
make[1]: Entering directory `/root/libdnet-1.7/src'
gcc -DHAVE_CONFIG_H -I. -I. -I../include -I../include    -g -O2 -Wall -c addr-util.c
gcc -DHAVE_CONFIG_H -I. -I. -I../include -I../include    -g -O2 -Wall -c addr.c
gcc -DHAVE_CONFIG_H -I. -I. -I../include -I../include    -g -O2 -Wall -c blob.c
gcc -DHAVE_CONFIG_H -I. -I. -I../include -I../include    -g -O2 -Wall -c ip-util.c
gcc -DHAVE_CONFIG_H -I. -I. -I../include -I../include    -g -O2 -Wall -c ip6.c
gcc -DHAVE_CONFIG_H -I. -I. -I../include -I../include    -g -O2 -Wall -c rand.c
gcc -DHAVE_CONFIG_H -I. -I. -I../include -I../include    -g -O2 -Wall -c strlcat.c
gcc -DHAVE_CONFIG_H -I. -I. -I../include -I../include    -g -O2 -Wall -c strlcpy.c
gcc -DHAVE_CONFIG_H -I. -I. -I../include -I../include    -g -O2 -Wall -c arp-ioctl.c
gcc -DHAVE_CONFIG_H -I. -I. -I../include -I../include    -g -O2 -Wall -c eth-linux.c
gcc -DHAVE_CONFIG_H -I. -I. -I../include -I../include    -g -O2 -Wall -c fw-ipchains.c
In file included from fw-ipchains.c:15:
/usr/include/linux/ip.h:95: error: syntax error before "__u8"
/usr/include/linux/ip.h:102: error: syntax error before "tot_len"
/usr/include/linux/ip.h:103: error: syntax error before "id"
/usr/include/linux/ip.h:104: error: syntax error before "frag_off"
/usr/include/linux/ip.h:105: error: syntax error before "ttl"
/usr/include/linux/ip.h:106: error: syntax error before "protocol"
/usr/include/linux/ip.h:107: error: syntax error before "check"
/usr/include/linux/ip.h:108: error: syntax error before "saddr"
/usr/include/linux/ip.h:109: error: syntax error before "daddr"
In file included from /usr/include/linux/tcp.h:21,
                 from fw-ipchains.c:16:
/usr/include/asm/byteorder.h:6:2: warning: #warning using private kernel header; include <endian.h> instead!
In file included from fw-ipchains.c:16:
/usr/include/linux/tcp.h:105: error: braced-group within expression allowed only inside a function
/usr/include/linux/tcp.h:105: error: enumerator value for `TCP_FLAG_CWR' not integer constant
/usr/include/linux/tcp.h:106: error: syntax error before "__u32"
/usr/include/linux/tcp.h:107: error: syntax error before "__u32"
/usr/include/linux/tcp.h:108: error: syntax error before "__u32"
/usr/include/linux/tcp.h:109: error: syntax error before "__u32"
/usr/include/linux/tcp.h:110: error: syntax error before "__u32"
/usr/include/linux/tcp.h:111: error: syntax error before "__u32"
/usr/include/linux/tcp.h:112: error: syntax error before "__u32"
/usr/include/linux/tcp.h:113: error: syntax error before "__u32"
/usr/include/linux/tcp.h:114: error: syntax error before "__u32"
In file included from fw-ipchains.c:25:
/usr/include/linux/netfilter_ipv4/ipchains_core.h:114: error: field `fwp_iph' has incomplete type
make[1]: *** [fw-ipchains.o] Error 1
make[1]: Leaving directory `/root/libdnet-1.7/src'
make: *** [all-recursive] Error 1


有知道怎么回事的xdjm支会我一下,非常感谢!
 楼主| 发表于 2004-4-18 13:39:39 | 显示全部楼层
终于找到了解决方案,FC1的ip.h和tcp.h确实有问题。

(1) The first set of errors,

/usr/include/linux/ip.h:95: syntax error before "__u8"
  /usr/include/linux/ip.h:102: syntax error before "tot_len"
  /usr/include/linux/ip.h:103: syntax error before "id"
  /usr/include/linux/ip.h:104: syntax error before "frag_off"
  /usr/include/linux/ip.h:105: syntax error before "ttl"
  /usr/include/linux/ip.h:106: syntax error before "protocol"
  /usr/include/linux/ip.h:107: syntax error before "check"
  /usr/include/linux/ip.h:108: syntax error before "saddr"
  /usr/include/linux/ip.h:109: syntax error before "daddr"

can be eliminated by adding <asm/types.h> to fw-ipchains.  This
adds the definition for __u8 and __u32.


(2) The second set of errors,

  /usr/include/linux/tcp.h:105: braced-group within expression allowed only
inside
   a function
  /usr/include/linux/tcp.h:105: enumerator value for `TCP_FLAG_CWR' not
integer co
  nstant
  /usr/include/linux/tcp.h:106: syntax error before "__u32"
  /usr/include/linux/tcp.h:107: syntax error before "__u32"
  /usr/include/linux/tcp.h:108: syntax error before "__u32"
  /usr/include/linux/tcp.h:109: syntax error before "__u32"
  /usr/include/linux/tcp.h:110: syntax error before "__u32"
  /usr/include/linux/tcp.h:111: syntax error before "__u32"
  /usr/include/linux/tcp.h:112: syntax error before "__u32"
  /usr/include/linux/tcp.h:113: syntax error before "__u32"
  /usr/include/linux/tcp.h:114: syntax error before "__u32"

Seem to stem from the following lines in tcp.h:

enum {
    TCP_FLAG_CWR = htonl(0x00800000)
    TCP_FLAG_ECE = htonl(0x00400000),
    TCP_FLAG_URG = htonl(0x00200000),
    TCP_FLAG_ACK = htonl(0x00100000),
    TCP_FLAG_PSH = htonl(0x00080000),
    TCP_FLAG_RST = htonl(0x00040000),
    TCP_FLAG_SYN = htonl(0x00020000),
    TCP_FLAG_FIN = htonl(0x00010000),
    TCP_RESERVED_BITS = htonl(0x0FC000000),
    TCP_DATA_OFFSET = htonl(0xF0000000)
};

It appears that the compiler does not like a function call in the
enumeration.  I checked this by doing the following:

   a. copying tcp.h to tcp_new.h
   b. removing the htonl in the above enumeration
   c. changing #include<linux/tcp.h> to #include<linux/tcp_new.h>

compiling removes these errors.  Additionally, in my new header I
made the change from an enumeration to a series of defines:

#define TCP_FLAG_CWR = htonl(0x00800000);
#define TCP_FLAG_ECE = htonl(0x00400000);
#define TCP_FLAG_URG = htonl(0x00200000);
#define TCP_FLAG_ACK = htonl(0x00100000);
#define TCP_FLAG_PSH = htonl(0x00080000);
#define TCP_FLAG_RST = htonl(0x00040000);
#define TCP_FLAG_SYN = htonl(0x00020000);
#define TCP_FLAG_FIN = htonl(0x00010000);
#define TCP_RESERVED_BITS = htonl(0x0FC000000);
#define TCP_DATA_OFFSET = htonl(0xF0000000);

which also removes the second set of errors.

In addition, these two changes remove the third set of errors

  /usr/include/linux/netfilter_ipv4/ipchains_core.h:114: field `fwp_iph' has
incom
  plete type
  /usr/include/linux/netfilter_ipv4/ipchains_core.h:122: confused by earlier
error
  s, bailing out

but introduce a new set of errors"

In file included from fw-ipchains.c:27
/usr/include/linux/netfilter_ipv4/ipchains_core.h:30: error: `fw_src' has
incomplete type

[several more of these types of errors...]

these errors can be fixed by making sure the file netinet/in.h is included
prior to
including any of the network related includes.


Thus with these modifications:

(1) addition of #include<asm/types.h>           as line 14
(2) addition of #include<netinet/in.h>          as line 15
(3) creation of tcp_new.h as described above
(4) modification of #include<linux/tcp.h> to #include<linux/tcp_new.h>

libdnet compiles and links start to finish.
发表于 2007-1-27 21:37:01 | 显示全部楼层
为了感谢你的贡献(我也遇到同样的问题),我特意注册(以前的ID忘了,哈哈)进来说声谢谢.
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部 返回列表