Under Linux when you compile C++ code using GCC or Clang there ends up being tons of debugging information that simply should not be there when you are not releasing open source software. The
strip command does not do enough to remove that information.
In order to do this you need to pass
-fvisibility-inlines-hidden to the compiler. This will hide symbol names and reduce the size of the binary. However, if you are linking to something like
boost, you won’t be able to hide symbols for the entire binary. In that case, you need to create two header files to programmatically change the visibility of your
In every code file / header file you’ll need to do this:
After you compile your program, you should then run
strip --strip-all --discard-all ... and also
sstrip ... from ELF Kickers.
Here’s a quick Python script I wrote to add the headers to .cpp files on Windows. It will look for the
stdafx include and insert the visibility include underneath it then add the pop header to the end of the file.