Release Runtime Error VS2008 - Problem Specific [closed]
I have a code piece that works perfectly fine when I execute it in Debug mode however it gives a runtime error when I execute it in Release mode. It is a console based application and I have added an external static library.
The problem does not lie in the piece of code since it crashes only when it using the library. Please keep in mind it works perfectly f开发者_如何学编程ine in Debug mode. Thanks in advance for your time.
Just because it works okay in debug mode doesn't mean there isn't an issue. Changing to release mode removes buffer padding, turns on optomisations etc. ...so it's not exactly the same piece of code.
Have you tried sticking some break points in to see how far it gets and to try and diagnose where it's crashing out?
What library are you calling? Are you passing it any buffers? have you initialised it properly?
Could it possibly be the case that the library you're using has a debug version as well as a release version? and you are perhaps linking the debug version in both builds?
Given that you get the error "defaultlib 'MSVCRTD' conflicts with use of other libs;" I would not be surprised if your problems might be caused by linking against different versions of the runtime. Make sure that all exe/libs/dll files are linked against the same version (either static or dynamic) of the runtime.
You say that you've got a crash due to a buffer overrun, so use a tool such as gflags to diagnose where this buffer overrun is happening.
There are many cases where code works absolutely fine in a debug build but crashes in a release build. The most common explanations are:
- Execution or class sizes may be different because of code inside
#ifdef _DEBUG
sections - On Windows, uninitialised variables are initialised to zero in a debug build. In a release build they will be random
精彩评论