Results 1 to 12 of 12

Thread: Unable to compile an Example

  1. #1
    Join Date
    Nov 2010
    Posts
    5
    Thanks
    2

    Default Unable to compile an Example

    Hi,
    I am attempting to compile a first example project "MoveBlocks" and facing a problem with compilation. The compiler cannot find the "main.moc" file which is included at the end of the source file "main.cpp"

    Here is the compiler output:
    Running build steps for project moveblocks...
    Configuration unchanged, skipping qmake step.
    Starting: "D:/Qt/2010.05/mingw/bin/mingw32-make.exe" -w
    mingw32-make: Entering directory `D:/Qt/2010.05/qt/examples/animation/moveblocks-build-desktop'

    D:/Qt/2010.05/mingw/bin/mingw32-make -f Makefile.Debug all

    mingw32-make[1]: Entering directory `D:/Qt/2010.05/qt/examples/animation/moveblocks-build-desktop'

    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"..\moveblocks" -I"." -I"..\..\..\mkspecs\win32-g++" -o tmp\obj\debug_shared\main.o ..\moveblocks\main.cpp

    mingw32-make[1]: Leaving directory `D:/Qt/2010.05/qt/examples/animation/moveblocks-build-desktop'

    mingw32-make: Leaving directory `D:/Qt/2010.05/qt/examples/animation/moveblocks-build-desktop'

    ..\moveblocks\main.cpp:319:20: error: main.moc: No such file or directory

    mingw32-make[1]: *** [tmp/obj/debug_shared/main.o] Error 1

    mingw32-make: *** [debug-all] Error 2

    The process "D:/Qt/2010.05/mingw/bin/mingw32-make.exe" exited with code %2.
    Error while building project moveblocks (target: Desktop)
    When executing build step 'Make'

    I am using Qt Creator 2.0.1 based on Qt 4.7.0 (32 bit) on WinXP
    Will appreciate all help.

  2. #2
    Join Date
    Jan 2006
    Location
    Belgium
    Posts
    1,938
    Thanked 268 Times in 268 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Wiki edits
    20

    Default Re: Unable to compile an Example

    Configuration unchanged, skipping qmake step.
    Oops, this happens from time to time, especially if you do not change the .pro file.
    This means the main.cpp file doesn't get processed by qmake resulting in a Makefile not calling the meta object compiler. This results in no .moc file being generated.

    Solution: Clean the project and rebuild.

  3. #3
    Join Date
    Nov 2010
    Posts
    5
    Thanks
    2

    Default Re: Unable to compile an Example

    tbscope,
    Thanks for your prompt reply BUT the problem still persists. I did the "clean", i even deliberately changed and saved the source file so make will compile it. It did, but the same problem still persists.

    Running build steps for project moveblocks...
    Starting: "D:/Qt/2010.05/mingw/bin/mingw32-make.exe" clean -w
    mingw32-make: Entering directory `D:/Qt/2010.05/qt/examples/animation/moveblocks-build-desktop'

    D:/Qt/2010.05/mingw/bin/mingw32-make -f Makefile.Debug clean

    mingw32-make[1]: Entering directory `D:/Qt/2010.05/qt/examples/animation/moveblocks-build-desktop'

    del tmp\moc\debug_shared\main.moc

    del tmp\obj\debug_shared\main.o

    mingw32-make[1]: Leaving directory `D:/Qt/2010.05/qt/examples/animation/moveblocks-build-desktop'

    D:/Qt/2010.05/mingw/bin/mingw32-make -f Makefile.Release clean

    Could Not Find D:\Qt\2010.05\qt\examples\animation\moveblocks-build-desktop\tmp\moc\debug_shared\main.moc

    Could Not Find D:\Qt\2010.05\qt\examples\animation\moveblocks-build-desktop\tmp\obj\debug_shared\main.o

    mingw32-make[1]: Entering directory `D:/Qt/2010.05/qt/examples/animation/moveblocks-build-desktop'

    del tmp\moc\release_shared\main.moc

    del tmp\obj\release_shared\main.o

    mingw32-make[1]: Leaving directory `D:/Qt/2010.05/qt/examples/animation/moveblocks-build-desktop'

    mingw32-make: Leaving directory `D:/Qt/2010.05/qt/examples/animation/moveblocks-build-desktop'

    Could Not Find D:\Qt\2010.05\qt\examples\animation\moveblocks-build-desktop\tmp\moc\release_shared\main.moc

    Could Not Find D:\Qt\2010.05\qt\examples\animation\moveblocks-build-desktop\tmp\obj\release_shared\main.o

    The process "D:/Qt/2010.05/mingw/bin/mingw32-make.exe" exited normally.
    Configuration unchanged, skipping qmake step.
    Starting: "D:/Qt/2010.05/mingw/bin/mingw32-make.exe" -w
    mingw32-make: Entering directory `D:/Qt/2010.05/qt/examples/animation/moveblocks-build-desktop'

    D:/Qt/2010.05/mingw/bin/mingw32-make -f Makefile.Debug all

    mingw32-make[1]: Entering directory `D:/Qt/2010.05/qt/examples/animation/moveblocks-build-desktop'

    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"..\moveblocks" -I"." -I"..\..\..\mkspecs\win32-g++" -o tmp\obj\debug_shared\main.o ..\moveblocks\main.cpp

    mingw32-make[1]: Leaving directory `D:/Qt/2010.05/qt/examples/animation/moveblocks-build-desktop'

    mingw32-make: Leaving directory `D:/Qt/2010.05/qt/examples/animation/moveblocks-build-desktop'

    ..\moveblocks\main.cpp:319:20: error: main.moc: No such file or directory

    mingw32-make[1]: *** [tmp/obj/debug_shared/main.o] Error 1

    mingw32-make: *** [debug-all] Error 2

    The process "D:/Qt/2010.05/mingw/bin/mingw32-make.exe" exited with code %2.
    Error while building project moveblocks (target: Desktop)
    When executing build step 'Make'

  4. #4
    Join Date
    Nov 2010
    Posts
    57
    Thanks
    4
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Unable to compile an Example

    add this to the moveblocks.pro

    INCLUDEPATH += tmp/moc/release_shared
    Last edited by pan; 15th November 2010 at 12:12. Reason: spelling corrections

  5. The following user says thank you to pan for this useful post:

    learner (15th November 2010)

  6. #5
    Join Date
    Jan 2006
    Location
    Belgium
    Posts
    1,938
    Thanked 268 Times in 268 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Wiki edits
    20

    Default Re: Unable to compile an Example

    Remove the Makefile, by hand if necessary.

    A tip:
    Try to build your code in a separate folder, a build folder. Then you can just remove the folder and create it again. This is the only way to be sure your software actually builds.

    Edit: actually Qt Creator already builds in a separate folder.
    You can just remove the moveblocks-build-desktop folder.
    Last edited by tbscope; 15th November 2010 at 11:30.

  7. #6
    Join Date
    Nov 2010
    Posts
    5
    Thanks
    2

    Default Re: Unable to compile an Example

    This worked! Thanks.
    Can you briefly explain why this is required? I do not see any reference for the DEBUG configuration in environment settings.

    To clarify my question - In Project settings, there is no place where we can specify any directories like you suggested for the release one.

    Another thing - in "Project" under "Run Settings" tab, I still see that executable for the release version is listed as being created in the debug directory, and this field is read-only. I suppose we should be able to change that to release - but how?
    Last edited by learner; 15th November 2010 at 15:45.

  8. #7
    Join Date
    Nov 2010
    Posts
    57
    Thanks
    4
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Unable to compile an Example

    I noticed this error:
    ..\moveblocks\main.cpp:319:20: error: main.moc: No such file or directory
    Saw that your main.cpp used #include "main.moc"
    so you just needed the path to the file to be added to the includepath list.

    Alternatively, you probably could have moved the main.moc file into same directory as your source files... but I haven't looked at this project in detail, to know what could break as a result of that.

  9. #8
    Join Date
    Jan 2006
    Location
    Belgium
    Posts
    1,938
    Thanked 268 Times in 268 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Wiki edits
    20

    Default Re: Unable to compile an Example

    Quote Originally Posted by pan View Post
    so you just needed the path to the file to be added to the includepath list.
    That would be a possible solution if the file was actually generated.
    However, that was not the case as you can see in the compiler output that.
    1. qmake decided not to update the Makefile
    2. only one file got compiled, main.cpp

  10. #9
    Join Date
    Nov 2010
    Posts
    5
    Thanks
    2

    Default Re: Unable to compile an Example

    I was just using one of the examples provided by Qt "as is" - which had the included main.moc at the end. In fact all of their sample examples have the same format. Maybe you have been with this long enough when this was not so.

  11. #10
    Join Date
    Nov 2010
    Posts
    57
    Thanks
    4
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Unable to compile an Example

    The file actually does exist along side the example code. In the directory I mentioned.
    I assume only one file was compiled because it didn't know the location of the second.

  12. #11
    Join Date
    Jan 2006
    Location
    Belgium
    Posts
    1,938
    Thanked 268 Times in 268 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Wiki edits
    20

    Default Re: Unable to compile an Example

    The qt examples do not contain .moc files. They are generated files.
    If they do, it's a packaging bug.

  13. The following user says thank you to tbscope for this useful post:

    learner (15th November 2010)

  14. #12
    Join Date
    Nov 2010
    Posts
    5
    Thanks
    2

    Default Re: Unable to compile an Example

    tbscope, yes thanks for your explanation on how these moc files get generated - your explanatory text seems to be gone - but I did read it. Thanks.

Similar Threads

  1. Unable to install QCA
    By viv_asp in forum Installation and Deployment
    Replies: 2
    Last Post: 30th January 2011, 08:28
  2. Unable to compile QT 4.6.2 on 64 bit Centos 5.4
    By Dave Augustus in forum Installation and Deployment
    Replies: 1
    Last Post: 7th March 2010, 15:25
  3. Replies: 1
    Last Post: 7th August 2008, 14:46
  4. Unable to load jpg on Mac OS
    By sgmurphy19 in forum Qt Programming
    Replies: 14
    Last Post: 31st January 2008, 13:49
  5. fftw unable to compile
    By superutsav in forum General Programming
    Replies: 7
    Last Post: 24th January 2006, 15:10

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.