在pkg-config搜索路径中找不到包xtables

时间:2017-10-22 13:23:34

标签: linux ubuntu mininet

我已下载iproute2。当我./configure && make && make install时,我得到了这些错误。

TC schedulers
 ATM    no
 IPT    Package xtables was not found in the pkg-config search path.
Perhaps you should add the directory containing `xtables.pc'
to the PKG_CONFIG_PATH environment variable
No package 'xtables' found
using iptables
 IPSET  yes

iptables modules directory: /lib/xtables
libc has setns: yes
SELinux support: no
ELF support: no
libmnl support: no
Berkeley DB: no

docs: latex: no
 WARNING: no docs can be built from LaTeX files
 sgml2html: no
 WARNING: no HTML docs can be built from SGML

make[1]: Entering directory `/home/mininet/iproute2-4.6.0/lib'
make[1]: Nothing to be done for `all'.
make[1]: Leaving directory `/home/mininet/iproute2-4.6.0/lib'
make[1]: Entering directory `/home/mininet/iproute2-4.6.0/ip'
make[1]: Nothing to be done for `all'.
make[1]: Leaving directory `/home/mininet/iproute2-4.6.0/ip'
make[1]: Entering directory `/home/mininet/iproute2-4.6.0/tc'    
gcc -Wall -Wstrict-prototypes  -Wmissing-prototypes -Wmissing-declarations -Wold-style-definition -Wformat=2 -O2 -I../include -DRESOLVE_HOSTNAMES -DLIBDIR=\"/usr/lib\" -DCONFDIR=\"/etc/iproute2\" -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE  -DHAVE_SETNS -DCONFIG_GACT -DCONFIG_GACT_PROB -DIPT_LIB_DIR=\"/lib/xtables\" -DYY_NO_INPUT   -c -o m_ipt.o m_ipt.c
    In file included from m_ipt.c:17:0:
    ../include/linux/if.h:106:19: error: redeclaration of enumerator ‘IFF_UP’
     #define IFF_UP    IFF_UP
                       ^
    ../include/linux/if.h:79:2: note: previous definition of ‘IFF_UP’ was here
      IFF_UP    = 1<<0,  /* sysfs */
      ^
    ../include/linux/if.h:107:25: error: redeclaration of enumerator ‘IFF_BROADCAST’
     #define IFF_BROADCAST   IFF_BROADCAST
                             ^
    ../include/linux/if.h:80:2: note: previous definition of ‘IFF_BROADCAST’ was here
      IFF_BROADCAST   = 1<<1,  /* __volatile__ */
      ^
    ../include/linux/if.h:108:21: error: redeclaration of enumerator ‘IFF_DEBUG’
     #define IFF_DEBUG   IFF_DEBUG
                         ^
    ../include/linux/if.h:81:2: note: previous definition of ‘IFF_DEBUG’ was here
      IFF_DEBUG   = 1<<2,  /* sysfs */
      ^
    ../include/linux/if.h:109:24: error: redeclaration of enumerator ‘IFF_LOOPBACK’
     #define IFF_LOOPBACK   IFF_LOOPBACK
                            ^
    ../include/linux/if.h:82:2: note: previous definition of ‘IFF_LOOPBACK’ was here
      IFF_LOOPBACK   = 1<<3,  /* __volatile__ */
      ^
    ../include/linux/if.h:110:27: error: redeclaration of enumerator ‘IFF_POINTOPOINT’
     #define IFF_POINTOPOINT   IFF_POINTOPOINT
                               ^
    ../include/linux/if.h:83:2: note: previous definition of ‘IFF_POINTOPOINT’ was here
      IFF_POINTOPOINT   = 1<<4,  /* __volatile__ */
      ^
    ../include/linux/if.h:111:26: error: redeclaration of enumerator ‘IFF_NOTRAILERS’
     #define IFF_NOTRAILERS   IFF_NOTRAILERS
                              ^
    ../include/linux/if.h:84:2: note: previous definition of ‘IFF_NOTRAILERS’ was here
      IFF_NOTRAILERS   = 1<<5,  /* sysfs */
      ^
    ../include/linux/if.h:112:23: error: redeclaration of enumerator ‘IFF_RUNNING’
     #define IFF_RUNNING   IFF_RUNNING
                           ^
    ../include/linux/if.h:85:2: note: previous definition of ‘IFF_RUNNING’ was here
      IFF_RUNNING   = 1<<6,  /* __volatile__ */
      ^
    ../include/linux/if.h:113:21: error: redeclaration of enumerator ‘IFF_NOARP’
     #define IFF_NOARP   IFF_NOARP
                         ^
    ../include/linux/if.h:86:2: note: previous definition of ‘IFF_NOARP’ was here
      IFF_NOARP   = 1<<7,  /* sysfs */
      ^
    ../include/linux/if.h:114:23: error: redeclaration of enumerator ‘IFF_PROMISC’
     #define IFF_PROMISC   IFF_PROMISC
                           ^
    ../include/linux/if.h:87:2: note: previous definition of ‘IFF_PROMISC’ was here
      IFF_PROMISC   = 1<<8,  /* sysfs */
      ^
    ../include/linux/if.h:115:24: error: redeclaration of enumerator ‘IFF_ALLMULTI’
     #define IFF_ALLMULTI   IFF_ALLMULTI
                            ^
    ../include/linux/if.h:88:2: note: previous definition of ‘IFF_ALLMULTI’ was here
      IFF_ALLMULTI   = 1<<9,  /* sysfs */
      ^
    ../include/linux/if.h:116:22: error: redeclaration of enumerator ‘IFF_MASTER’
     #define IFF_MASTER   IFF_MASTER
                          ^
    ../include/linux/if.h:89:2: note: previous definition of ‘IFF_MASTER’ was here
      IFF_MASTER   = 1<<10, /* __volatile__ */
      ^
    ../include/linux/if.h:117:21: error: redeclaration of enumerator ‘IFF_SLAVE’
     #define IFF_SLAVE   IFF_SLAVE
                         ^
    ../include/linux/if.h:90:2: note: previous definition of ‘IFF_SLAVE’ was here
      IFF_SLAVE   = 1<<11, /* __volatile__ */
      ^
    ../include/linux/if.h:118:25: error: redeclaration of enumerator ‘IFF_MULTICAST’
     #define IFF_MULTICAST   IFF_MULTICAST
                             ^
    ../include/linux/if.h:91:2: note: previous definition of ‘IFF_MULTICAST’ was here
      IFF_MULTICAST   = 1<<12, /* sysfs */
      ^
    ../include/linux/if.h:119:23: error: redeclaration of enumerator ‘IFF_PORTSEL’
     #define IFF_PORTSEL   IFF_PORTSEL
                           ^
    ../include/linux/if.h:92:2: note: previous definition of ‘IFF_PORTSEL’ was here
      IFF_PORTSEL   = 1<<13, /* sysfs */
      ^
    ../include/linux/if.h:120:25: error: redeclaration of enumerator ‘IFF_AUTOMEDIA’
     #define IFF_AUTOMEDIA   IFF_AUTOMEDIA
                             ^
    ../include/linux/if.h:93:2: note: previous definition of ‘IFF_AUTOMEDIA’ was here
      IFF_AUTOMEDIA   = 1<<14, /* sysfs */
      ^
    ../include/linux/if.h:121:23: error: redeclaration of enumerator ‘IFF_DYNAMIC’
     #define IFF_DYNAMIC   IFF_DYNAMIC
                           ^
    ../include/linux/if.h:94:2: note: previous definition of ‘IFF_DYNAMIC’ was here
      IFF_DYNAMIC   = 1<<15, /* sysfs */
      ^
    In file included from ../include/xtables.h:16:0,
                     from ../include/iptables.h:5,
                     from m_ipt.c:18:
    /usr/include/net/if.h:111:8: error: redefinition of ‘struct ifmap’
     struct ifmap
            ^
    In file included from m_ipt.c:17:0:
    ../include/linux/if.h:189:8: note: originally defined here
     struct ifmap {
            ^
    In file included from ../include/xtables.h:16:0,
                     from ../include/iptables.h:5,
                     from m_ipt.c:18:
    /usr/include/net/if.h:126:8: error: redefinition of ‘struct ifreq’
     struct ifreq
            ^
    In file included from m_ipt.c:17:0:
    ../include/linux/if.h:226:8: note: originally defined here
     struct ifreq {
            ^
    In file included from ../include/xtables.h:16:0,
                     from ../include/iptables.h:5,
                     from m_ipt.c:18:
    /usr/include/net/if.h:176:8: error: redefinition of ‘struct ifconf’
     struct ifconf
            ^
    In file included from m_ipt.c:17:0:
    ../include/linux/if.h:278:8: note: originally defined here
     struct ifconf  {
            ^
    In file included from ../include/iptables.h:5:0,
                     from m_ipt.c:18:
    ../include/xtables.h:34:29: fatal error: xtables-version.h: No such file or directory
     #include <xtables-version.h>
                                 ^
    compilation terminated.
    make[1]: *** [m_ipt.o] Error 1
    make[1]: Leaving directory `/home/mininet/iproute2-4.6.0/tc'
    make: *** [all] Error 2

请帮助

更新

我最终更新内核并且可以正常工作!

1 个答案:

答案 0 :(得分:1)

TC schedulers
 ATM    no
 IPT    Package xtables was not found in the pkg-config search path.

在Ubuntu上安装libxtables-dev。我找不到Fedora的类似软件包。在Fedora上,您可能需要从源代码构建。

Ubuntu的

$ apt-cache search xtables
libip4tc-dev - Development files for libiptc
libip4tc0 - netfilter libi4pt library
libip6tc-dev - Development files for libiptc
libip6tc0 - netfilter libipt library
libiptc-dev - Development files for libiptc
libiptc0 - netfilter libipt library
libxtables-dev - netfilter xtables library
libxtables11 - netfilter xtables library

Fedora的

$ dnf search xtables
No matches found.
$ dnf search libxtables
No matches found.
Perhaps you should add the directory containing `xtables.pc'
to the PKG_CONFIG_PATH environment variable

如果您在Ubuntu上安装/usr/local/lib(或在Fedora上安装/usr/local/lib64),那么您会看到如下内容:

$ ls -Al /usr/local/lib/pkgconfig/
total 88
-rw-r--r-- 1 root root  228 Oct 22 08:15 expat.pc
-rw-r--r-- 1 root root  726 Oct 19 23:56 gnutls-dane.pc
-rw-r--r-- 1 root root  911 Oct 19 23:56 gnutls.pc
-rw-r--r-- 1 root root 1199 Oct 22 08:53 guile-2.2.pc
-rw-r--r-- 1 root root  563 Oct 22 08:13 hogweed.pc
-rw-r--r-- 1 root root  315 Oct 16 06:56 libcrypto.pc
-rw-r--r-- 1 root root 1678 Oct 16 06:58 libcurl.pc
-rw-r--r-- 1 root root  860 Oct 16 06:52 libidn.pc
...

配置时,您可以执行以下操作:

INSTALL_PREFIX="/usr/local"
INSTALL_LIBDIR="$INSTALL_PREFIX/lib"

OPT_PKGCONFIG=("$INSTALL_LIBDIR/pkgconfig")
OPT_CPPFLAGS=("-I$INSTALL_PREFIX/include" "-DNDEBUG")
OPT_CFLAGS=("$SH_MARCH" "$SH_NATIVE")
OPT_CXXFLAGS=("$SH_MARCH" "$SH_NATIVE")
OPT_LDFLAGS=("$SH_MARCH" "-Wl,-rpath,$INSTALL_LIBDIR" "-L$INSTALL_LIBDIR")
OPT_LIBS=("-ldl" "-lpthread")
...

   PKG_CONFIG_PATH="${OPT_PKGCONFIG[*]}" \
   CPPFLAGS="${OPT_CPPFLAGS[*]}" \
   CFLAGS="${OPT_CFLAGS[*]}" CXXFLAGS="${OPT_CXXFLAGS[*]}" \
   LDFLAGS="${OPT_LDFLAGS[*]}" LIBS="${OPT_LIBS[*]}" \
./configure --enable-shared --prefix="$INSTALL_PREFIX" --libdir="$INSTALL_LIBDIR"
   <other config options>