c++ - 使用 MinGW 的 g++ 在 Windows XP 中编译 Qt 程序

标签 c++ qt mingw

我有一个 stub Qt 应用程序,但我不断收到编译器错误

#include <QApplication>

int main(int argc, char *argv[])
 {
     return 0;
 }

据我所知,我使用了 qmake -projectqmake 命令 他们正确地完成了工作。当我随后在命令中调用 make 时 行我收到以下错误:

g++ -c -O2 -frtti -fexceptions -mthreads -Wall -DUNICODE -DQT_LARGEFILE_SUPPORT
-DQT_NO_DEBUG -DQT_GUI_LIB -DQT_CORE_LIB -DQT_THREAD_SUPPORT -DQT_NEEDS_QMAIN -I
'../../../../qt/include/QtCore' -I'../../../../qt/include/QtCore' -I'../../../..
/qt/include/QtGui' -I'../../../../qt/include/QtGui' -I'../../../../qt/include' -
I'.' -I'c:/qt/include/ActiveQt' -I'release' -I'.' -I'../../../../qt/mkspecs/defa
ult' -o release/Main.o Main.cpp
cc1plus.exe: Invalid option 'threads'
make[1]: *** [release/Main.o] Error 1
make: *** [release] Error 2

我在 Google 上的搜索告诉我线程很重要,但不是如何保留 修复此错误。任何帮助将不胜感激。

编辑(从 OP 留下的答案复制):

我现在得到:

g++ -enable-stdcall-fixup -Wl,-enable-auto-import -Wl,-enable-runtime-pseudo-rel oc 
-Wl,-s -pthread -Wl -Wl,-subsystem,windows -o release/raytrace.exe 
object_scr ipt.raytrace.Release  -L'c:/qt/lib' -lmingw32 -lqtmain -lQtGui -lgdi32 
-lcomdlg3 2 -loleaut32 -limm32 -lwinmm -lwinspool -lmsimg32 -lQtCore -lkernel32 
-luser32 - lshell32 -luuid -lole32 -ladvapi32 -lws2_32 
g++: unrecognized option `-pthread' 
/cygnus/cygwin-b20/H-i586-cygwin32/i586-cygwin32/bin/ld: cannot open -lmsimg32: 
No such file or directory collect2: 
ld returned 1 exit status make[1]: *** 
[release/raytrace.exe] Error 1 make: *** [release] Error 2

最佳答案

++米洛

我只使用 MinGW 在 Windows 上编译 Qt,这是确保您拥有所需一切的最简单方法。

这是开源 Qt 版本的链接: http://trolltech.com/downloads/opensource/appdev/windows-cpp

使用“或下载带有 MinGW 编译器的 Qt:大小:149,3 Mb”链接。

使用 MinGW 的另一种方法是使用 MinGW 编译 Qt,然后编译您的应用程序,但这取决于您是在 MSYS 中编译还是仅使用 MinGW。

关于c++ - 使用 MinGW 的 g++ 在 Windows XP 中编译 Qt 程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/199092/

相关文章:

c++ - python 结构体中的 vector

c - 为什么我不能使用 CodeBlocks 从我的 C 源代码调用汇编函数?

c++ - AC_CHECK_LIB在mingw64中失败

c++ - 如何调试段错误

c++ - 如何检查文件是否已通过其他进程更改?

c++ - 在 C++ 动态链接函数中调用 Octave 排序?

c++ - QDialogProgress的分配和删除

c++ - 如何在Windows中使用Valgrind和vera++

visual-studio - 从 Qt SDK 包管理器为 Visual Studio 安装 Qt 插件

mingw - 如何卸载msys2?