Recently I have installed VS Addin from Qt Software and I imported my .pro project to VS2008.
Generally, all works fine, with one small but annoying exception.
Suppose I have a file.cpp with has a class which declares that it is a Q_OBJECT.
So, as such the file is MOC-ed and moc_file.cpp is generated, and is available in Solution under “Generated files”. So far so good.
The funny thing is, when I change something in file.cpp (add a line, for example), and save the file using Ctrl+S, the moc_file.cpp becomes excluded from build (you can see a no entry sign on the icon). And I hit lots of typical linker errors when I press F7 to build a solution. In order to fix the situation, I need to go to the properties of moc_file.cpp and change “Exclude from build” from “Yes” to “No”. Then everything works fine.
Is someone else experiencing the same? Am I doing something wrong?
Problem solved. I found out that in my hand-crafted .pro file describing my project, I had MOC_DIR specified as:
After importing to Visual Studio directory for “Generated files” was the same for both Release and Debug. So, when my active configuration was Debug for example, when I saved a file it became excluded from build because it was sensible for Release-related file – just as rpg and Andrew suggested.
After changing the directory to .moc\$(ConfigurationName) the problem is no longer seen (and I see 2 versions of each generated file in my solution – one for each configuration).
Thank you for your help everyone!