I tried to use GSL DLL and its relevant functions of Histogram. My program is working in Debug version, however, not successful in Release version. Both didn't report any error during build.
I tried to find possible reason for that. It seems that one of functions of Histogram doesn't work in release version. It is "gsl_histogram_fprintf(histfile, h, "%f", "%f")". Other functions is fine.
I am using VC++ 2010 express. Any idea to solve this problem? Thanks in advance.
That's a common problem. It usually means you have memory misuse errors somewhere; things like dangling references, buffer overruns, ... that sort of thing.
kbw's right, experienced C++ programmers know this as a common phenomenon...it's a dreaded result of using C style storage (things like malloc/free, printf, arrays), and skipping the modern C++ counterparts (like std::shared_ptr, refusing naked new/delete, vector instead of arrays, etc).
Here's the reason.
The debug version of your program includes some kind of memory tracking extension built into your program when compiled in debug mode. Every allocation is made with extra space, and that memory is intentionally initialized with coded meanings (0xdeadbeef, 0xcdcdcdcd, etc). If you cause buffer overruns, fail to delete or free memory, the debug system can report that to you.
None of those things are done for a release build. Memory is organized differently in the release version (it will be faster and smaller). Problems which are actually shielded from view by the debug mode build are then made obvious in the release build.
Check the output window of Visual Studio AFTER a normal exit from your program. It may be telling you things about the run which the compiler can't tell at compile time.
I was surprised because the code is short and very simple, not complicated. It didn't have too many variables to manage the memory. I don't know this is because the functions of GSL DLL have problem themselves in Release version built or my mistake in programming.
Until now, I have to use the debug version. Although it is very slow to deal with huge data, it is working anyway.