我在编译Qt框架版本4.1.4的源代码时遇到了问题。 (有关确切的编译器错误文本,请参见附图)
我正在使用Qt的这个来源(http://get.qt.nokia.com/qt/source/qt-win-opensource-src-4.1.4.zip)
我正在使用具有GCC版本4.5.0.1的MinGW(最新来自http://sourceforge.net/projects/mingw/files/)
对我来说,似乎某些函数原型在qatomic.h
中是差异的,而GCC包含winbase.h
,可能是由于Qt 4.1.4有点旧。
谁能告诉我如何解决这个问题? 通过改变MinGW版本?还是其他一些环境设定?
如果有人已经使用MinGW成功编译了Qt 4.1.4,那会很高兴请告诉我使用的是哪个版本的MinGW和GCC?
编译器输出:
D:\Qt\qt-win-opensource-src-4.1.4>mingw32-make
cd src && mingw32-make -f Makefile
mingw32-make[1]: Entering directory `D:/Qt/qt-win-opensource-src-4.1.4/src'
cd winmain && mingw32-make -f Makefile
mingw32-make[2]: Entering directory `D:/Qt/qt-win-opensource-src-4.1.4/src/winma
in'
mingw32-make -f Makefile.Debug all
mingw32-make[3]: Entering directory `D:/Qt/qt-win-opensource-src-4.1.4/src/winma
in'
g++ -c -g -g -Wall -frtti -fexceptions -DQT_THREAD_SUPPORT -DUNICODE -DQT_LARGEF
ILE_SUPPORT -DQT_NEEDS_QMAIN -DQT_NO_CAST_TO_ASCII -DQT3_SUPPORT -DQT_MOC_COMPAT
-I"D:/Qt/qt-win-opensource-src-4.1.4/include" -I"tmp" -I"D:/Qt/qt-win-opensourc
e-src-4.1.4/include/QtCore" -I"d:\Qt\qt-win-opensource-src-4.1.4\include\qtmain"
-I"tmp" -I"D:/Qt/qt-win-opensource-src-4.1.4/include/ActiveQt" -I"tmp\moc\debug
_shared" -I"." -I"..\..\mkspecs\win32-g++" -o tmp\obj\debug_shared\qtmain_win.o
qtmain_win.cpp
In file included from D:/Qt/qt-win-opensource-src-4.1.4/include/QtCore/arch/qato
mic.h:1:0,
from D:/Qt/qt-win-opensource-src-4.1.4/include/QtCore/../../src
/corelib/thread/qatomic.h:31,
from D:/Qt/qt-win-opensource-src-4.1.4/include/QtCore/qatomic.h
:1,
from D:/Qt/qt-win-opensource-src-4.1.4/include/QtCore/../../src
/corelib/tools/qbytearray.h:28,
from D:/Qt/qt-win-opensource-src-4.1.4/include/QtCore/qbytearra
y.h:1,
from qtmain_win.cpp:25:
D:/Qt/qt-win-opensource-src-4.1.4/include/QtCore/arch/../../../src/corelib/arch/
windows/arch/qatomic.h:154:87: error: declaration of C function 'long int Interl
ockedCompareExchange(long int*, long int, long int)' conflicts with
c:\mingw\bin\../lib/gcc/mingw32/4.5.0/../../../../include/winbase.h:1689:13: err
or: previous declaration 'LONG InterlockedCompareExchange(volatile LONG*, LONG,
LONG)' here
D:/Qt/qt-win-opensource-src-4.1.4/include/QtCore/arch/../../../src/corelib/arch/
windows/arch/qatomic.h:155:69: error: declaration of C function 'long int Interl
ockedIncrement(long int*)' conflicts with
c:\mingw\bin\../lib/gcc/mingw32/4.5.0/../../../../include/winbase.h:1702:13: err
or: previous declaration 'LONG InterlockedIncrement(volatile LONG*)' here
D:/Qt/qt-win-opensource-src-4.1.4/include/QtCore/arch/../../../src/corelib/arch/
windows/arch/qatomic.h:156:69: error: declaration of C function 'long int Interl
ockedDecrement(long int*)' conflicts with
c:\mingw\bin\../lib/gcc/mingw32/4.5.0/../../../../include/winbase.h:1693:13: err
or: previous declaration 'LONG InterlockedDecrement(volatile LONG*)' here
D:/Qt/qt-win-opensource-src-4.1.4/include/QtCore/arch/../../../src/corelib/arch/
windows/arch/qatomic.h:157:74: error: declaration of C function 'long int Interl
ockedExchange(long int*, long int)' conflicts with
c:\mingw\bin\../lib/gcc/mingw32/4.5.0/../../../../include/winbase.h:1694:13: err
or: previous declaration 'LONG InterlockedExchange(volatile LONG*, LONG)' here
mingw32-make[3]: *** [tmp\obj\debug_shared\qtmain_win.o] Error 1
mingw32-make[3]: Leaving directory `D:/Qt/qt-win-opensource-src-4.1.4/src/winmai
n'
mingw32-make[2]: *** [debug-all] Error 2
mingw32-make[2]: Leaving directory `D:/Qt/qt-win-opensource-src-4.1.4/src/winmai
n'
mingw32-make[1]: *** [sub-winmain-make_default-ordered] Error 2
mingw32-make[1]: Leaving directory `D:/Qt/qt-win-opensource-src-4.1.4/src'
mingw32-make: *** [sub-src-make_default-ordered] Error 2
答案 0 :(得分:0)
看起来你有Qt的重复包含。编译时从includepaths中排除C:\ mingw \ lib \ gcc \ mingw32 \ 4.5.0
答案 1 :(得分:0)