首页 > 代码库 > qt-everywhere-opensource-src-4.8.1 出错:error: 'IPV6_MULTICAST_HOPS' was not declared in this scope

qt-everywhere-opensource-src-4.8.1 出错:error: 'IPV6_MULTICAST_HOPS' was not declared in this scope

在编译:qt-everywhere-opensource-src-4.8.1出现如下错误:

/opt/buildroot-2011.11/arm920t/usr/bin/arm-linux-g++ -c -include .pch/release-shared-emb-arm/QtNetwork -pipe -fno-exceptions -O2 -fvisibility=hidden -fvisibility-inlines-hidden -Wall -W -D_REENTRANT -fPIC -DQT_SHARED -DQT_BUILD_NETWORK_LIB -DQT_NO_USING_NAMESPACE -DQT_NO_CAST_TO_ASCII -DQT_ASCII_CAST_WARNINGS -DQT3_SUPPORT -DQT_MOC_COMPAT -DQT_USE_QSTRINGBUILDER -DQT_NO_DEBUG -DQT_CORE_LIB -D_LARGEFILE64_SOURCE -D_LARGEFILE_SOURCE -I../../mkspecs/qws/linux-arm-g++ -I. -I../../include/QtCore -I../../include -I../../include/QtNetwork -I.rcc/release-shared-emb-arm -Ikernel -I.moc/release-shared-emb-arm -o .obj/release-shared-emb-arm/qnativesocketengine_unix.o socket/qnativesocketengine_unix.cpp
socket/qnativesocketengine_unix.cpp: In member function 'int QNativeSocketEnginePrivate::option(QAbstractSocketEngine::SocketOption) const':
socket/qnativesocketengine_unix.cpp:249: error: 'IPV6_MULTICAST_HOPS' was not declared in this scope
socket/qnativesocketengine_unix.cpp:261: error: 'IPV6_MULTICAST_LOOP' was not declared in this scope
socket/qnativesocketengine_unix.cpp: In member function 'bool QNativeSocketEnginePrivate::setOption(QAbstractSocketEngine::SocketOption, int)':
socket/qnativesocketengine_unix.cpp:354: error: 'IPV6_MULTICAST_HOPS' was not declared in this scope
socket/qnativesocketengine_unix.cpp:366: error: 'IPV6_MULTICAST_LOOP' was not declared in this scope
socket/qnativesocketengine_unix.cpp: In member function 'bool QNativeSocketEnginePrivate::nativeJoinMulticastGroup(const QHostAddress&, const QNetworkInterface&)':
socket/qnativesocketengine_unix.cpp:681: error: 'IPV6_JOIN_GROUP' was not declared in this scope
socket/qnativesocketengine_unix.cpp: In member function 'bool QNativeSocketEnginePrivate::nativeLeaveMulticastGroup(const QHostAddress&, const QNetworkInterface&)':
socket/qnativesocketengine_unix.cpp:695: error: 'IPV6_LEAVE_GROUP' was not declared in this scope
socket/qnativesocketengine_unix.cpp: In member function 'QNetworkInterface QNativeSocketEnginePrivate::nativeMulticastInterface() const':
socket/qnativesocketengine_unix.cpp:710: error: 'IPV6_MULTICAST_IF' was not declared in this scope
socket/qnativesocketengine_unix.cpp: In member function 'bool QNativeSocketEnginePrivate::nativeSetMulticastInterface(const QNetworkInterface&)':
socket/qnativesocketengine_unix.cpp:741: error: 'IPV6_MULTICAST_IF' was not declared in this scope
gmake[1]: *** [.obj/release-shared-emb-arm/qnativesocketengine_unix.o] Error 1
gmake[1]: Leaving directory `/home/chenzhenwei/embededproject/systools/qt4/qt-everywhere-opensource-src-4.8.1/src/network'
gmake: *** [sub-network-make_default-ordered] Error 2

明显,缺少IPV6_MULTICAST_XXXX等一系列定义,在src/network/socket/目录下创建ctags之后,发现这些宏定义在bits/in.h里面存在,我直接把头文件添加到里面,有显示重定义错误。

In file included from socket/qnativesocketengine_unix.cpp:42:
/opt/buildroot-2011.11/arm920t/usr/arm-unknown-linux-uclibcgnueabi/sysroot/usr/include/bits/in.h:22:3: error: #error "Never use <bits/in.h> directly; include <netinet/in.h> instead."
In file included from socket/qnativesocketengine_unix.cpp:42:
/opt/buildroot-2011.11/arm920t/usr/arm-unknown-linux-uclibcgnueabi/sysroot/usr/include/bits/in.h:84: error: field 'ip_dst' has incomplete type
/opt/buildroot-2011.11/arm920t/usr/arm-unknown-linux-uclibcgnueabi/sysroot/usr/include/bits/in.h:91: error: field 'imr_multiaddr' has incomplete type
/opt/buildroot-2011.11/arm920t/usr/arm-unknown-linux-uclibcgnueabi/sysroot/usr/include/bits/in.h:92: error: field 'imr_address' has incomplete type
/opt/buildroot-2011.11/arm920t/usr/arm-unknown-linux-uclibcgnueabi/sysroot/usr/include/bits/in.h:100: error: field 'ipi_spec_dst' has incomplete type
/opt/buildroot-2011.11/arm920t/usr/arm-unknown-linux-uclibcgnueabi/sysroot/usr/include/bits/in.h:101: error: field 'ipi_addr' has incomplete type
In file included from /opt/buildroot-2011.11/arm920t/usr/arm-unknown-linux-uclibcgnueabi/sysroot/usr/include/netinet/in.h:368,
                 from ../../mkspecs/qws/linux-arm-g++/../../linux-g++/qplatformdefs.h:79,
                 from ../../mkspecs/qws/linux-arm-g++/qplatformdefs.h:42,
                 from socket/qnativesocketengine_p.h:58,
                 from socket/qnativesocketengine_unix.cpp:45:
/opt/buildroot-2011.11/arm920t/usr/arm-unknown-linux-uclibcgnueabi/sysroot/usr/include/bits/in.h:82: error: redefinition of 'struct ip_opts'
/opt/buildroot-2011.11/arm920t/usr/arm-unknown-linux-uclibcgnueabi/sysroot/usr/include/bits/in.h:83: error: previous definition of 'struct ip_opts'
/opt/buildroot-2011.11/arm920t/usr/arm-unknown-linux-uclibcgnueabi/sysroot/usr/include/bits/in.h:89: error: redefinition of 'struct ip_mreqn'
/opt/buildroot-2011.11/arm920t/usr/arm-unknown-linux-uclibcgnueabi/sysroot/usr/include/bits/in.h:90: error: previous definition of 'struct ip_mreqn'
/opt/buildroot-2011.11/arm920t/usr/arm-unknown-linux-uclibcgnueabi/sysroot/usr/include/bits/in.h:97: error: redefinition of 'struct in_pktinfo'
/opt/buildroot-2011.11/arm920t/usr/arm-unknown-linux-uclibcgnueabi/sysroot/usr/include/bits/in.h:98: error: previous definition of 'struct in_pktinfo'
看来,他只需要这几个宏定义,那么我们就直接把他需要的几个宏定义copy过来用可以了。

#define IPV6_MULTICAST_IF   17
#define IPV6_MULTICAST_HOPS 18
#define IPV6_MULTICAST_LOOP 19
#define IPV6_JOIN_GROUP     20
#define IPV6_LEAVE_GROUP    21


OK,问题到此解决。


qt-everywhere-opensource-src-4.8.1 出错:error: 'IPV6_MULTICAST_HOPS' was not declared in this scope