Main.moc: No such file or directory
-
Hi, I just installed Qt SDK 4.7.1 on windows Vista. I faced a problem when trying to build examples provided in the Qt. The example which I used was animatedtiles.
Please help me to solve this. This is my first time try.bq.
-
Please tell us, which compiler you're using (MSVC, mingw, madde?) and post the complete error message.
-
Hello!
I have the same problem. I've installed QtCreator 2.01 based on Qt 4.7.0 and MingGW.
Here is the compile output:
Running build steps for project animatedtiles...
Configuration unchanged, skipping qmake step.
Starting: "C:/Qt/2010.05/mingw/bin/mingw32-make.exe" -w
mingw32-make: Entering directory `C:/Qt/2010.05/qt/examples/animation/animatedtiles-build-desktop'C:/Qt/2010.05/mingw/bin/mingw32-make -f Makefile.Debug all
mingw32-make[1]: Entering directory `C:/Qt/2010.05/qt/examples/animation/animatedtiles-build-desktop'
C:/Qt/2010.05/qt/bin/moc.exe -DUNICODE -DQT_LARGEFILE_SUPPORT -DQT_DLL -DQT_GUI_LIB -DQT_CORE_LIB -DQT_THREAD_SUPPORT -DQT_NEEDS_QMAIN -I'../../../include/QtCore' -I'../../../include/QtGui' -I'../../../include' -I'../../../include/ActiveQt' -I'tmp/moc/debug_shared' -I'../animatedtiles' -I'.' -I'../../../mkspecs/win32-g++' -D__GNUC__ -DWIN32 ../animatedtiles/main.cpp -o tmp/moc/debug_shared/main.moc
g++ -c -g -frtti -fexceptions -mthreads -Wall -DUNICODE -DQT_LARGEFILE_SUPPORT -DQT_DLL -DQT_GUI_LIB -DQT_CORE_LIB -DQT_THREAD_SUPPORT -DQT_NEEDS_QMAIN -I'../../../include/QtCore' -I'../../../include/QtGui' -I'../../../include' -I'../../../include/ActiveQt' -I'tmp/moc/debug_shared' -I'../animatedtiles' -I'.' -I'../../../mkspecs/win32-g++' -o tmp/obj/debug_shared/main.o ../animatedtiles/main.cpp
c:/Qt/2010.05/qt/bin/rcc.exe -name animatedtiles ../animatedtiles/animatedtiles.qrc -o tmp/rcc/debug_shared/qrc_animatedtiles.cpp
g++ -c -g -frtti -fexceptions -mthreads -Wall -DUNICODE -DQT_LARGEFILE_SUPPORT -DQT_DLL -DQT_GUI_LIB -DQT_CORE_LIB -DQT_THREAD_SUPPORT -DQT_NEEDS_QMAIN -I'../../../include/QtCore' -I'../../../include/QtGui' -I'../../../include' -I'../../../include/ActiveQt' -I'tmp/moc/debug_shared' -I'../animatedtiles' -I'.' -I'../../../mkspecs/win32-g++' -o tmp/obj/debug_shared/qrc_animatedtiles.o tmp/rcc/debug_shared/qrc_animatedtiles.cpp
g++ -enable-stdcall-fixup -Wl,-enable-auto-import -Wl,-enable-runtime-pseudo-reloc -mthreads -Wl -Wl,-subsystem,windows -o debug/animatedtiles.exe tmp/obj/debug_shared/main.o tmp/obj/debug_shared/qrc_animatedtiles.o -L'c:/Qt/2010.05/qt/lib' -L'c:/Qt/2010.05/qt/lib' -lmingw32 -lqtmaind -lQtGuid4 -lQtCored4
mingw32-make[1]: Leaving directory `C:/Qt/2010.05/qt/examples/animation/animatedtiles-build-desktop'
C:/Qt/2010.05/mingw/bin/mingw32-make -f Makefile.Release all
mingw32-make[1]: Entering directory `C:/Qt/2010.05/qt/examples/animation/animatedtiles-build-desktop'
g++ -c -O2 -frtti -fexceptions -mthreads -Wall -DUNICODE -DQT_LARGEFILE_SUPPORT -DQT_DLL -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_CORE_LIB -DQT_THREAD_SUPPORT -DQT_NEEDS_QMAIN -I'../../../include/QtCore' -I'../../../include/QtGui' -I'../../../include' -I'../../../include/ActiveQt' -I'tmp/moc/release_shared' -I'../animatedtiles' -I'.' -I'../../../mkspecs/win32-g++' -o tmp/obj/release_shared/main.o ../animatedtiles/main.cpp
mingw32-make[1]: Leaving directory `C:/Qt/2010.05/qt/examples/animation/animatedtiles-build-desktop'
../animatedtiles/main.cpp:132:20: error: main.moc: No such file or directory
mingw32-make[1]: *** [tmp/obj/release_shared/main.o] Error 1
mingw32-make: Leaving directory `C:/Qt/2010.05/qt/examples/animation/animatedtiles-build-desktop'
mingw32-make: *** [release-all] Error 2
The process "C:/Qt/2010.05/mingw/bin/mingw32-make.exe" exited with code %2.
Error while building project animatedtiles (target: Desktop)
When executing build step 'Make' -
same problem.
and, if I registered without getting the activated e-mail, how could I could do ?
-
in .pro file, add this to solve the problem.
INCLUDEPATH += tmp/moc/release_shared
-
Hi.
Thank you so much!
Can you explain me why this happens? I don't know if every time I'd want to create a project this is gonna happen.
-
This is a special version to include the moc code. All QObject based classes must be processed by the moc tool ("meta object compiler":http://doc.qt.nokia.com/latest/moc.html). In regular qmake project, the moc files are added to the source file list automatically behind the scenes. The are then included in the Makefile and the object file list for the linking stage. Instead of compiling the moc generated files manually, one can #include them into a regular cpp file too. This is what happens in your case.