Qt moc.exe没有生成*.moc文件

Dou*_*son 5 qt qmake nmake

我正在尝试构建qtestlib/tutorial1示例,但是当我运行时没有生成testqstring.moc文件nmake(我在Windows XP SP3上运行Qt 4.5.2).
我将testqstring.cpp从tutorial目录复制到我的构建目录(C:\ sandboxes\testqstring),并从Qt命令提示符运行我的MS Visual Studio 8安装中的vsvars32.bat文件来添加VS环境变量.

根据教程,我应该运行:

> qmake -project "CONFIG += qtestlib"
> qmake
> nmake
Run Code Online (Sandbox Code Playgroud)

当我这样做时,输出nmake是:

C:/Apps/Qt/2009.03/qt/bin\moc.exe -DUNICODE -DQT_LARGEFILE_SUPPORT -DQT_DLL -DQT_TESTLIB_LIB -DQT_GUI_LIB -DQT_CORE_LIB -DQT_THREAD_SUPPORT -I"....\Apps\Qt\2009.03\qt\include\QtCore" -I"....\Apps\Qt\2009.03\qt\include\QtGui"-I"....\Apps\Qt\2009.03\qt\include\QtTest"-I"....\Apps\Qt\2009.03\qt\include"-I"." -I"....\Apps\Qt\2009.03\qt\include\ActiveQt"-I"debug"-I"....\Apps\Qt\2009.03\qt\mkspecs\win32-g ++"-D__GNUC__ - DWIN32 testqstring.cpp -o debug\testqstring.moc

g ++ -c -g -frtti -fexceptions -mthreads -Wall -DUNICODE -DQT_LARGEFILE_SUPPORT -DQT_DLL -DQT_TESTLIB_LIB -DQT_GUI_LIB -DQT_CORE_LIB -DQT_THREAD_SUPPORT -I"....\Apps\Qt\2009.03\qt\include\QtCore"-I" ....\Apps\Qt\2009.03\qt\include\QtGui"-I"....\Apps\Qt\2009.03\qt\include\QtTest"-I"....\Apps\Qt\2009.03\qt\include"-I"." -I"....\Apps\Qt\2009.03\qt\include\ActiveQt"-I"debug"-I"....\Apps\Qt\2009.03\qt\mkspecs\win32-g ++"-o debug\testqstring.o testqstring.cpp

testqstring.cpp:63:27:testqstring.moc:没有这样的文件或目录
NMAKE:致命错误U1077:'C:\ Apps\Qt\2009.03\mingw\bin\g ++.EXE':返回代码'0x1'停止.
NMAKE:致命错误U1077:'C:\ PROGRA~1\MICROS~3\VC\BIN \nmake.exe':返回代码'0x2'停止.

所以,我可以看到正在调用moc.exe来生成debug/testqstring.moc,但是从不生成该文件.

感谢您提供的任何和所有指导.

roh*_*npm 4

看起来您正在尝试使用nmakeMinGW 进行构建。 nmake是一个MSVC工具。

如果您想使用 MinGW 进行构建,则必须使用mingw32-make. 如果您想使用 MSVC 进行构建,则必须使用使用 MSVC 构建的 Qt(这意味着您必须自己构建它或拥有商业许可证)。