Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to identify if a library is DEBUG or RELEASE build?

Tags:

c++

Our project is using many static libraries to build the application. How can we make sure we are using release version of libraries in release build of application?

We are making mistakes by taking debug library in release application build.

I am looking for an elegant way in which I can write a module in that we can check whether a particular library is release or debug and report it if not matching. Our application is written in C/C++. (Platform MSVC & GCC)

like image 578
ManojMarathayil Avatar asked May 11 '09 11:05

ManojMarathayil


People also ask

How do I know if my library is debugging or released?

Assuming you want to find out whether or not the library contains debugging symbols, you have ran the right command for it: objdump --syms *. a | grep debug usually produces non-empty output for the objects that do contain debugging symbols.

What is the difference between a debug build and a release build?

By default, Debug includes debug information in the compiled files (allowing easy debugging) while Release usually has optimizations enabled. As far as conditional compilation goes, they each define different symbols that can be checked in your program, but they are language-specific macros.

How do I know if binary is debug or release Linux?

If it is debug, it will display all the actual source code call you do. If it is release, it will just display the founded symbol from the symbol table.

What is the difference between debug and release mode?

Debug Mode: When we are developing the application. Release Mode: When we are going to production mode or deploying the application to the server. Debug Mode: The debug mode code is not optimized. Release Mode: The release mode code is optimized.


1 Answers

Yes. You can check the Characteristics field of the IMAGE_FILE_HEADER structure of the file. If the library is a release build, then bit 0x0200 (DEBUG_STRIPPED) will be set; on a debug build, it will be clear.

You can find technical information on the PE Format used by Windows EXEs and DLLs, to see how to retrieve that structure, in various places on the 'net (such as here).

like image 148
Head Geek Avatar answered Sep 19 '22 21:09

Head Geek