64 bit C++ Exe Sizes With Mingw w64

Started by Frederick J. Harris, January 01, 2013, 09:33:03 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Frederick J. Harris

Wow!  With James Fuller's help I got a 64 bit C++ compiler working.  I had noticed the 64 bit exes were a bit larger when compiled with Microsoft's compilers, to the tune of 10 to 15 percent larger.  But with the experimental 64 bit Mingw suite I came in over five times bigger.  A basically do nothing program that compiled to 23 K as a 32 bit exe came in 123 K as 64 bit - even with the -s switch, which minimizes size.  I guess things have been getting out of hand for some time now.
  •  

Charles Pegge

Sounds like a bloated run-time library to me. On the generous side, 64 bit code could be 50% larger then 32bit code, due to the way in which parameters are passed.

James C. Fuller

Fred,
  The main size bloat is iostream with MinGW, both 32 and 64. If you don't need it don't include it or do as I do and upx the exe. :)

James
  •  

Frederick J. Harris

No, its not iostream James.  iostream has for many years been one of my pet peeves about C++.  So I never use it other than to make fun of it.  What I'm thinking is that the compiler just needs more work.  Just my guess though.  Could be any number of things, like Charles said.  The Code::Blocks team hasn't used it yet as the main Mingw compiler, so I expect they don't feel its ready yet.  Also, I tried compiling a somewhat more complicated program with it and ran into some more variable type errors I need to look into.  I'll work on it tomorrow a bit hopefully.  I'm glad I tried it and appreciate your help.
  •  

James C. Fuller

Fred,
  I may be mistaken but I think the Code::Blocks download with MinGW is 32bit only and is only version 4.6.? while even the non-TDM and TDM64 is 4.7.x

FYI

//----------------------------------------------------
// this is missing From MinGWTDM64 stdlib.h
//----------------------------------------------------
#if defined(__MINGW32__) || defined(__MINGW64__)
  #ifndef MAX_PATH
    #define MAX_PATH 260
  #endif
#endif
//----------------------------------------------------


James
  •  

Frederick J. Harris

Been working on it today some.  Found out that to get the smaller exe size one must use the Os switch in addition to the -s switch.  Using this for a program I want named ProgEx41_x64.exe ...

g++  Main.cpp  -oProgEx41_x64.exe  -mwindows  -m64  -Os  -s

...will give me about 42K.  Using only the -s switch, which apparently only removes debug symbols, give me about 125K ...

g++  Main.cpp  -oProgEx41_x64.exe  -mwindows  -m64  -s

So I guess the Os plus s both optimizes for size, and removes debug symbols.

A couple years ago I had worked up some additions to my C and C++ tutorials on command line compiling, but I never posted them.  I think I'll see if I can't bring them up to snuff, so to speak, and further refine them to try to work across x86 / x64 with both Mingw and MSVC.





  •