Jump to content
  • Advertisement
Sign in to follow this  
XTAL256

Forcing Visual Studio to compile an out-of-date file

This topic is 2990 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I have a project that is using Qt with Visual Studio 2008. Qt comes with it's own build tool (qmake) which outputs a makefile for VS to use. So i do not actually use any build settings in VS's project properties, i just set nmake to use the makefile.

There are two problems i am having with this.
Firstly, whenever i run the project (F5) it says that it's out if date and asks me to re-build. This always happens, even if i have just built it a second ago. I don't know if anyone knows how to use Qt's build tools but i suspect this is more to do with the makefile that it generates, and so would be VS's problem.
How do i get VS to pick up that the files are up-to-date? And how does it work, anyway?

The second (maybe not related to Qt) is that it never re-compiles the resource (.rc) file when a file it #includes is changed. I define the version number in a header file called "resource.h", then i have a resource file "win_resources.rc" which includes it and uses that version number in the VS_VERSION_INFO.
But when i change the header file, VS will re-compile every source file that includes it (most of the files in my project) but not the resource file.
How can i force it to compile it either when it's changes or, failing that, all the time?

Share this post


Link to post
Share on other sites
Advertisement
Are you regenerating the makefile from Qt for every build? I believe if VS sees the makefile has been touched, it assumes the entire project needs to be rebuilt -- which is the correct behavior in case you had changed a build rule.

Another possibility, dependent on how the makefile is setup, is that VS can't see a difference in the timestamps of the intermediate files in the multistage Qt build process. I ran in to a similar problem with using a custom VS project for a Qt application.

There is a Qt addin for VS that adds a new Qt project type that nicely wraps up all the Qt build oddities far better than any other Qt+VS combination I've used. I'd highly recommend giving it a try, it was the only solution I found to the unneeded builds I had experienced with Qt + VS.

Share this post


Link to post
Share on other sites
Look into the "custom build step" pane of the file settings. This has nothing to do with make files - Qt in a standard Visual Studio setup adds custom build steps to every header which need to be mocced. And there probably lays your solution to issue #1: The moc step there declares an input, an output, and (last time I checked) the Moccer itsself as an additional input. Visual Studio works much like any other make system: it checks whether any of the inputs is more recent than the output. Maybe the file date on your QT-Installation (or the qtmoc executable specifically) is trashed. That would lead to recompilation every time.

Issue two might be solved in a similar way: have a look at the resource file's settings. Maybe there's a way to specify additional input files to the resource build process. Visual Studio should find this for itsself, but if it doesn't this might be a solution to trick the compiler into the correct behaviour.

Share this post


Link to post
Share on other sites
Quote:
Original post by Drakonite
Are you regenerating the makefile from Qt for every build? I believe if VS sees the makefile has been touched, it assumes the entire project needs to be rebuilt -- which is the correct behavior in case you had changed a build rule.

You might be right. I use the following build command in VS:
qmake -config release && nmake
That would run qmake everytime, which (i think) would always generate a new makefile.
qmake really only needs to be ran whenever (like you said) a build rule is changed, which would only occur if the Qt project file (.pro) is changed OR a ui form (.ui) is changed. I'm not sure how i would get it to only run qmake when needed.

Quote:
There is a Qt addin for VS that adds a new Qt project type that nicely wraps up all the Qt build oddities far better than any other Qt+VS combination I've used. I'd highly recommend giving it a try, it was the only solution I found to the unneeded builds I had experienced with Qt + VS.

Yes, but i think that is only for the full version of VS, as the Express version (which i forgot to mention i am using) does not support plugins.

Share this post


Link to post
Share on other sites
Hmm, i seem to only have a problem posting when i attempt to post the contents of the Qt .pro file. Perhaps the server was seeing some special characters and getting stuck trying to parse it.

I guess i won't post it then. If anyone wants to see it, i will upload it to an external site.


Schrompf, i assume that you have the Qt plug-in for Visual Studio given that you were explaining the build steps it uses. Is there any way you could tell me what those build steps are, or give me a project file or something so that i can look at it? That way i could try and setup my build settings in a similar way

Share this post


Link to post
Share on other sites
Anyone else have any ideas? I PM'ed Schrompf about his suggestion but he cannot offer any more help.

He gave me a project that had been made using the Qt plugin, but that used a normal project with custom build steps for each file that needed it (ones that needed to be ran through the moc). I am using the makefile that Qt generates and a makefile VS project (uses nmake), so that setup is different from Schrompf's.
But the principle should be the same, both should be able to correctly detect if a project needs rebuilding. So i think it is in the way i have it setup.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!