Results 1 to 5 of 5

Thread: MOC Error

  1. #1
    Join Date
    Jun 2011
    Posts
    203
    Thanks
    7
    Thanked 4 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default MOC Error

    Hi,

    If I understand this correctly, the moc files that get generated when the project is built that basically add code that provides signals and slots functionality and probably other things.

    I'm getting an error however which basically says that in one of these generated moc files,

    "No such file or directory" for one of the .h files that is in my project structure. My files are all in the same folder including the .pro file so I don't think I need to add INCLUDEPATH in the .pro file. I'm not sure why the compiler isn't seeing it.

    I've searched through other peoples problems with this but that hasn't helped everyone has different ways of solving these problems that don't apply in my case e.g. people switching from windows to ubuntu or simply deleting the build files and building a fresh project.

    Any ideas where to look to solve this?

    I've had issues with moc files before but never managed to fully understand how to solve them, would like to get over this bridge this time.

  2. #2
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,230
    Thanks
    302
    Thanked 864 Times in 851 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: MOC Error

    In Visual Studio, moc creates "moc_xyz.cpp" files into "GeneratedFiles/Debug" and "GeneratedFiles/Release" subdirectories of the main project directory. If you are using Qt Creator and doing an out-of-source build, probably a similar thing happens in the build directory. An include file error probably means that moc has not used a relative path when writing the code for the generated file, or the cpp compiler has not been configured with the right set of include paths.

    Have you moved or renamed files sometime before this error occurred? Or changed the build location? Maybe manually running qmake again will fix things.
    <=== The Great Pumpkin says ===>
    Please use CODE tags when posting source code so it is more readable. Click "Go Advanced" and then the "#" icon to insert the tags. Paste your code between them.

  3. #3
    Join Date
    Jun 2011
    Posts
    203
    Thanks
    7
    Thanked 4 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default Re: MOC Error

    Yes doing an out of source build. It's the default as far as I know.

    moc is using relative paths i.e. in my case:

    Qt Code:
    1. "#include "../../Source Folder/MyHeader.h"
    To copy to clipboard, switch view to plain text mode 

    but that's the correct directory to find the header file!

    No, haven't moved or renamed anything, freshly created class files and dropping the error right out of the box. I've barely written any code! Just compiling as I go and boom, error petty much with a Virgin file.

    Nor have I changed the build location.

    Of course, it compiles if I manually set the path of the header file in the moc file, but I would much rather figure out why it's generated incorrectly in the first place.
    Last edited by Atomic_Sheep; 20th September 2017 at 01:54.

  4. #4
    Join Date
    Jun 2011
    Posts
    203
    Thanks
    7
    Thanked 4 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default Re: MOC Error

    If I manually use an absolute path that is.

  5. #5
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,230
    Thanks
    302
    Thanked 864 Times in 851 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: MOC Error

    Sorry, can't help you much. I rarely use Qt Creator and use Visual Studio and/or CMake instead. Maybe someone more familiar with Qt Creator can offer a solution.
    <=== The Great Pumpkin says ===>
    Please use CODE tags when posting source code so it is more readable. Click "Go Advanced" and then the "#" icon to insert the tags. Paste your code between them.

Similar Threads

  1. Replies: 14
    Last Post: 2nd August 2015, 22:07
  2. Replies: 3
    Last Post: 19th November 2014, 19:44
  3. Replies: 4
    Last Post: 29th April 2014, 16:20
  4. : error: [\NokiaQtSDK\Symbian\SDK\epoc32\release\gcce\udeb\V ideo.exe] Error 1
    By ranjit.kadam in forum Qt for Embedded and Mobile
    Replies: 1
    Last Post: 1st May 2011, 22:11
  5. Replies: 3
    Last Post: 23rd January 2011, 12:15

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.