title: For identical c++ source file, its gcc executable is 655 times bigger in Windows than in Linux. Why this much difference?
body: <p>I was testing this simple c++ code on my Windows 8.1, Intel i7-3517U 64 bit laptop with GCC 4.8.2.  </p>
  
  <pre class="lang-cpp prettyprint-override"><code>#include&lt;iostream&gt;
  
  using namespace std; 
  
  int main(int argc, char **argv){
     cout &lt;&lt; "This test code will simply display any arguments passed." &lt;&lt; endl ;
     for(int i=0; i&lt;argc; i++){
        cout &lt;&lt; argv[i] &lt;&lt; endl ;
     }
     return 0 ;
  }
  </code></pre>
  
  <p>Surprisingly, after compiling, the executable turned out to be of <strong>5905KB</strong>. Out of curiosity, i tried compiling the same file with the same GCC version on Linux Fedora 20 64 bit machine. And the executable was just <strong>9KB</strong>.</p>
  
  <p>After doing various optimization using  <code>g++ -Ox -o fileWithOx.exe file.cpp</code>  (x=1,2,3,s), Windows executable were nearly same in size. After doing some research, and following <a href="http://www.mingw.org/wiki/Large_executables" rel="nofollow noreferrer">MinGW's advise</a> i tried compiling them without debugging information using strip <code>g++ -s -o fileWithStrip.exe file.cpp</code>, but the executable was still <strong>597KB</strong> large. </p>
  
  <p>While on the other hand, Linux executable were of just <strong>6-13KB</strong> for same options.</p>
  
  <p>Doing some experiments, <a href="http://www.cplusplus.com/forum/windows/3430/" rel="nofollow noreferrer">some more research</a> &amp; <a href="https://stackoverflow.com/questions/1042773/gcc-c-hello-world-program-exe-is-500kb-big-when-compiled-on-windows-how">stack overflowing</a>, i was nearly convinced that the gigantic size is due to <strong>iostream</strong> linking to many other header files and/or generating some initialization code. </p>
  
  <p>But my doubt is that iostream is used both in Windows as well as in Linux. Then why so much difference in size? I know that Windows and Linux executable work differently. <strong>But 655 times bigger</strong>, isn't this a bit extreme?</p>