Adel Benhamida
Adel Benhamida

Reputation: 49

big size after compiling a c++ code

My IDE is Code::Blocks

I wrote a simple c++ code

#include <iostream>
using namespace std;
int main(void){
   cout << "hello, World!";
}

I compiled it using gcc 7.1 with c++14 support

when I choose Debug mode & build&run the app it produces :

Output file is bin\Debug\learn.exe with size 13.56 MB

Note : size is 13.56 MB

after that, I chose Release Mode then I built & ran the app, it gave me this :

Output file is bin\Release\learn.exe with size 1.12 MB

Now the Output is 1.12 MB

I am confused if there was a data loss or something like that, maybe libraries .... ?

Is it normal?

Upvotes: 0

Views: 131

Answers (1)

Lightness Races in Orbit
Lightness Races in Orbit

Reputation: 385405

The whole point of debug builds is that the executable incorporates things that you can, y'know, debug with. That includes information that would usually not be kept, like the names of variables.

The code is also less terse because it has not been optimised as much (optimisations being unhelpful to the debugging process).

You can definitely expect debug builds to be larger.

Upvotes: 1

Related Questions