开发者

vs2010 cannot run file in compiled mode, but executes properly in debug mode

Recently I'm writing a program using Qt in Visual Studio 2010. I have configured my Qt settings properly because I ran that program successfully before. But now I can't run the program in compiled mode (outside the IDE), but it runs properly in debug mode.

My operating system is Windows 7, and I am using Qt 4.7

开发者_如何学Go

PS. It does not say missing DLLs, just crashes silently....


If it executes in release mode but crashes it may not be anything to do with Qt.

Possibilities - you have different environments set in debug/release modes. Are you running this from the commandline in the Debug\Release directories or from ctrl-f5 inside MSVC? So one version may be finding the wrong set of dlls, perhaps an earlier version?

Or more likley, there is a bug in your code that only shows up in release mode. The most common is an uninitialized variable, debug mode generally sets all variables to zero while in release mode they can contain any random value.


Maybe your code depends on some files stored in application folder and those files are missing in release folder ?

Or maybe there are many Qt versions installed in your system and the one used in VS is different from the one visible to the application ?


I had a similar problem recently, and it took me a long time to fix it. The debug version worked because it was slower than the release version, not being optimised. The release version, being too fast, was waiting on a mutex before it was set. I found the problem by compiling the debug version with optimisation explicitly enabled. If you think it might be a similar timing problem, you might want to try this.

Edited to add: Another possibility is that you are breaking some anti-aliasing rule or whatever, that doesn't do any harm if your code is not optimised. Again, try enabling optimisation in your debug build. (Also, stepping through fully optimised code can be surreal.)


If this is the first time you tried to run anything you built in VS in release mode on your machine this is usually a problem of not having the VS runtime libraries installed. Installing VS does not install it's own runtime libraries into the system. While running inside the IDE will work with debug and release versions, running outside of the IDE will not work. This is a huge PITA, find the correct version of vcredist. It is somewhere in the Visual Studio tree (can't remember where) install it and move on from there.

You can see if any version of vcredist is installed in the "Add/Remove Programs" settings dialog, but it is always a problem to figure out if the one that is installed is exactly the right one

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜