Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why does the executable binary file contain paths of included header files?

Tags:

c++

c

wxwidgets

Why does the compiled and linked executable file contain paths of header files included in my source code? I am using the wxWidgets library and compile with Visual Studio 2013 and gcc. What are these header files used for? If it is a compiler option, how can I disable it to avoid this?

Build configuration: release, static linking.

Example

like image 812
Gokhan Bora Avatar asked May 09 '15 12:05

Gokhan Bora


People also ask

Why is it necessary to include header file in a program?

Header files serve two purposes. System header files declare the interfaces to parts of the operating system. You include them in your program to supply the definitions and declarations you need to invoke system calls and libraries.

What is executable binary files?

A binary executable file is a file in a machine language for a specific processor. Binary executable files contain executable code that is represented in specific processor instructions. These instructions are executed by a processor directly. A binary file, however, can have text strings (ASCII and/or Unicode).

Why is an executable called a binary?

Now, in Linux you'll often hear "binaries" when referring to "binary executable files" - programs. This is because while sources of most programs (written in high-level languages) are plain text, compiled executables are binary. Since there are quite a few compiled formats (a.

What is a binary executable file created from the source code?

Source code files represent the computing language-specific data declarations and instructions that constitute a software module, routine, procedure, or class. A source code file is intended to be compiled into an executable binary file that can be run on the target computing system.


2 Answers

There may be several explanations for such strings to appear in the executable file:

  • You may have debugging information bundled in the executable for the debugger to use. Use strip to remove that, or do not use the -g compile option. You should also compile with NDEBUG defined to disable debugging code and assertions. It is usually the case for the Release mode, but you may want to double check.
  • Some functions may use __FILE__ for tracing or logging purposes. __FILE__ expands to the source file name at the point of macro expansion, which may be a source or a header file. One such function is assert(): it is actually a macro that expands to a test and some error reporting code that includes the current filename.
  • Some sources may have static source ids in the form of static char arrays to keep track of source code versions. This approach is quite obsolete, but many old sources still have them.

Look for such things in the source files or header files whose name appear in the executable and fix the problems.

like image 190
chqrlie Avatar answered Sep 27 '22 21:09

chqrlie


wxwidgets has many asserts in its header files (e.g. in wx/string.h as you noticed), all using the wxASSERT macro defined in wx/debug.h In order to disable these, you can #define wxDEBUG_LEVEL 0 prior to including any wxwidget headers.

like image 35
Hagen von Eitzen Avatar answered Sep 27 '22 20:09

Hagen von Eitzen