Ashley Meah
Ashley Meah

Reputation: 131

Windows PE from Visual C++ compiler debug database

I complied a very simple application, it just prints out hell world to a C++ Win32 console. I came across a reference to the debug database file in HxD, never noticed it before, I was building it for "debug" and not "release". I changed this, the release executable also includes this reference.

Does anyone know if I am doing something wrong as far as if I was going to release this, I build it for release right? What would be the "proper" way to build a executable for release.

I also see some project assembly XML further down, I am interested in minimizing the Windows PE executable, am I right to think there must be complier options? Maybe this is all to do with the IDE and using just a text editor and barebones complier is what I am looking for?

HxD screenshot

Upvotes: 1

Views: 312

Answers (1)

Neitsa
Neitsa

Reputation: 8176

Even in release mode Visual C++ will generate a program database (*.PDB ; the full path is embedded in the binary and can be used by some debuggers) and a manifest file (the XML you see in your executable).

Disable PDB generation

  • In Visual C++, go to your project properties (Edit > xxx Properties [ALT+F7]).
  • In your project properties go to Configuration Properties > Linker > Debugging
  • Set Generate Debug info to No (it should say Yes (/DEBUG) by default)

Warning: You'll now not have any symbols while debugging.

Disable Manifest file

  • In Visual C++, go to your project properties (Edit > xxx Properties [ALT+F7]).
  • In your project properties go to Configuration Properties > Linker > Manifest File
  • Set Generate Manifest to No (it should say Yes (/MANIFEST) by default)

You might also want to check properties in Configuration Properties > Manifest tool.

Warning: manifests are notably used for DLL side-by-side loading, COM isolation and User Access control. Make sure that your executable runs fine when Manifest generation has been disabled.

There are various tricks to reduce a PE file (besides obvious compression) to get a minimal file right from compiler and linker passes, these tricks are well known in the demoscene, some of them are explained here. Bear in mind that it comes with some drawbacks and need thorough testing to see if the resulting PE file behaves correctly.

Upvotes: 1

Related Questions