问题
Recently, I'm working on intergrating the physics engine into my graphics engine program. Before this, I always build my program in Debug mode because I feel Debug means safe and more information to let me know where is wrong.
In my program, I built Assimp in Release mode, but I still used it in the Debug mode until now. For now, I build Bullet Physics in Release mode beacuse of the performance is huge different in Debug mode. If you want to know how slow it is, you could see this.
The important thing is that I could not use this *.lib file in Debug mode ever, so I have a question, when or why do you change to Release mode from Debug mode or on the other hand. Or using the Release library in Debug mode either? For now, I think I need to change to Release mode permanently for Bullet Physics, and don't know if this is good or bad.
Edit:
I know the benifit for release and debug mode, because there is a lot of possible duplicated articles in stackoverflow, but what I want to know is when you make a program what the decision for choosing or just because encounter a performace problem so need to rebuild the program into release mode like me. I just want to clarify a little different between the posiible duplicated articles :)
There are four cases for this question.
Case 1. Start a new project and programming in Debug mode, because of... .
Case 2. Start a new project and programming in Release mode, because of... .
Case 3. Work in Debug mode a period of time, but change to Release mode because of ... .
Case 4. Work in Release mode a period of time, but change to Debug mode because of ... .
I really want to know what the decisions in the four cases. I'm in the case 3, because of the performace of the Bullet Physics, I decide to make program to be release mode forever, and also make other debug library to rebuild to release mode. In case 3, the question is, I just use the third party library, so do I need to use Debug mode for any reason? Or I just go to release mode?
For case 1&2, Is there any decision why you let the debug mode or release mode to build your new program.
For case 4, I could not think why make a man to change the Release mode to Debug mode, but maybe there is a actual cases? except just build the library you could make this decision.
If my question is not clear enough, please let me know.
回答1:
"Debug mode" and "Release mode" are two predefined set of compiler switches. You can however override them, and create intermediate forms. C++ commonly benefits a lot from inlining, so a debug-with-inlining build is a reasonable intermediate form. Another common variation is to use the Release version of the C & C++ libraries even in debug builds.
You can even override switches on individual file level. Your bullet physics are likely correct, so you might want to check if they can be compiled with
That said, it's quite common to flip between debug and release mode, when tackling different problems.
回答2:
Use debug (unoptimized) builds when you need to debug something. They produce (slow) code that matches your source closely so you can more easily debug.
Use release (optimized) builds for code that you ship. They produce code that run a lot faster (orders of magnitude often), but debugging optimized code is really difficult since the generated code is often quite different from the source you wrote.
Mixing objects built as debug/release in the same program is often a recipie for disaster (crashes) (especially with Microsofts compiler); so just don't do that.
来源:https://stackoverflow.com/questions/40575482/debug-mode-or-release-mode