Important: Please read the Qt Code of Conduct -

Where to store moc_ and qrc_ generated files

  • I'm currently designing a procedure for automating the moc, uic and rcc steps when building Qt applications with Visual Studio Express (doesn't support the plug-in). I have a simple question: why should the generated moc_ and qrc_ .ccp files have to have separate debug and release versions stored in the 'debug' and 'release' directories when (in my experience) a comparision shows the two version to be identical?

  • I cannot think of a reason to put them in separate directories. I usually add a @MOC_DIR = moc@ line to my .pro file, which makes the moc files end up there, for both debug and release builds. Same goes for qrc, I would assume.

  • Moderators

    It's a Windows thing, where qmake uses separate directories for debug and release builds. On other platforms, all files are stored in the same place (unless, of course, you specify otherwise in .pro file). You can force output dir just as ludde suggested (probably. I'm a Linux person. It definitely workse here).

  • Many thanks for your helpful replies - I shall assume that having two versions in QCreator and the Visual Studio plug-n is just a convenience thing.

  • I have had further thoughts about the conclusion reached above. Qt projects on Windows generated by qmake (or QtCreator) produce two preprocessor DEFINE lists differing by one entry; the 'release' version includes QT_NO_DEBUG and the 'debug' version does not. So theoretically it is possible that the use, or not, of this directive in a header file containing a Q_OBJECT reference could result in two differing moc_xxx.cpp files. Such a case must be extremely rare but clearly must be allowed for in generally available apps like qmake and QtCreator. Maintaining two project source collections is very inconvenient and I intend to ignore the problem.

    As forums are a geat source of trouble shooting info I thought that submitting this new conclusion would be useful. Thank you.

Log in to reply