Author Topic: 64 bit C++ Exe Sizes With Mingw w64  (Read 4845 times)

0 Members and 1 Guest are viewing this topic.

Offline Frederick J. Harris

  • Hero Member
  • *****
  • Posts: 914
  • User-Rate: +16/-0
    • Frederick J. Harris
64 bit C++ Exe Sizes With Mingw w64
« on: January 01, 2013, 09:33:03 PM »
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.

Offline Charles Pegge

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 672
  • User-Rate: +27/-1
    • Charles Pegge
Re: 64 bit C++ Exe Sizes With Mingw w64
« Reply #1 on: January 01, 2013, 11:11:22 PM »
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.

Offline James C. Fuller

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 595
  • User-Rate: +11/-8
Re: 64 bit C++ Exe Sizes With Mingw w64
« Reply #2 on: January 01, 2013, 11:20:13 PM »
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

Offline Frederick J. Harris

  • Hero Member
  • *****
  • Posts: 914
  • User-Rate: +16/-0
    • Frederick J. Harris
Re: 64 bit C++ Exe Sizes With Mingw w64
« Reply #3 on: January 02, 2013, 12:37:44 AM »
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.

Offline James C. Fuller

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 595
  • User-Rate: +11/-8
Re: 64 bit C++ Exe Sizes With Mingw w64
« Reply #4 on: January 02, 2013, 11:33:07 AM »
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
Code: [Select]
//----------------------------------------------------
// this is missing From MinGWTDM64 stdlib.h
//----------------------------------------------------
#if defined(__MINGW32__) || defined(__MINGW64__)
  #ifndef MAX_PATH
    #define MAX_PATH 260
  #endif
#endif
//----------------------------------------------------

James

Offline Frederick J. Harris

  • Hero Member
  • *****
  • Posts: 914
  • User-Rate: +16/-0
    • Frederick J. Harris
Re: 64 bit C++ Exe Sizes With Mingw w64
« Reply #5 on: January 02, 2013, 08:27:49 PM »
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.