2

I am using mysql cpp library . I checkout the recent copy from there bzr trunk and used cmake to generate library .

First time I used release mode and second time I used debug mode to build. The both library have

a mysql_debug.cpp
U mysql_debug

Is there a way to check in program (C or C++ code) or using nm that library is Release library or Debug library

Vivek Goel
  • 22,942
  • 29
  • 114
  • 186
  • Release vs Debug issues are rather windows specific. Under linux there should not be binary incompatibilities. – Alexandre C. Mar 24 '11 at 07:51
  • @ Alexandre C but I am getting strange problem , if I link with release build of the mysql cpp , the program is crashing randomly but if I link it with debug one. It is working fine . – Vivek Goel Mar 24 '11 at 08:01
  • You could give your two libraries different names when you build them. – Erik Mar 24 '11 at 08:06
  • @Alexandre: Release vs. Debug is not related to Windows. These are only the default configuration names, that Visual Studio creates for your, when you create a project. The difference between these sample configurations are the amount of run time check code, specified with /RTC. Such settings should be possible with every compiler. – harper Mar 24 '11 at 11:57
  • @harper yes, but there is the additional problem of the version of the runtime library you link with under windows, and also the binary incompatibility between STL classes in "debug" and "release" mode. Under linux, there is usually no such incompatibility, at least for the standard library (things may be different here, since a debug version of a given library may store extra information inside classes). – Alexandre C. Mar 24 '11 at 13:24
  • @Alexandre: So it's good to hear that Vivek targets Linux (CentOS). – harper Mar 24 '11 at 15:10
  • @^ I will try to upload sample program and both lib on tomorrow. – Vivek Goel Mar 24 '11 at 15:17

3 Answers3

1

I have seen false negatives with nm so I do not trust it. When I want to check to see if an object file has debug info I run objdump -x on the object file or library and look to see if there are headers that say dbg, stabs, or dwarf. This is not the most elegant solution by any means, but it has never been wrong and it is real easy to see the difference in when you have a debug and release build to compare.

ltc
  • 3,313
  • 1
  • 28
  • 26
0

Do objdump -x , store the output in a file and search for dll . If you see the library linking with windows release library then its Release version otherwise debug version.

Vihaan Verma
  • 12,815
  • 19
  • 97
  • 126
0

Differences between debug and release builds are typically due to invalid code being optimized differently, rather than incompatibilities, so it is sheer luck that one of them works and the other doesn't (it could also be the other way 'round).

Run the program under valgrind to see whether that flags any illegal accesses.

Simon Richter
  • 28,572
  • 1
  • 42
  • 64