Menu

How to compile a small exe? Hello.exe is .5mb

2007-10-29
2012-09-26
  • Dave Turner

    Dave Turner - 2007-10-29

    I just downloaded Bloodshed dev-c++ for the first time, opened up the Hello project, compiled it, everything went smoothly, but hello.exe is 474,990 bytes! I had a look at the compiler/project settings and it didn't appear that any Debug stuff was turned on although I could be wrong

    So whats the secret to compiling small exes?
    Thanks

     
    • Anonymous

      Anonymous - 2007-10-30

      Your log does not include the code compilation only the linking. The -g3 option is a compiler option not a linker option so if it is there you won't see in in the linker invokation. To see the full build perform a "Rebuild All"; otherwise compiler is only invoked if the code has been modified.

      You are using C++ compilation. What does the code look like? It it is C++ code then it is not "the same program" as you compiled in LCC since that does not support C++. Using the C++ standard library pulls in a lot of baggage that you won't be using in this trivial example.

      In a non-trivial application however, you will probably be using much more of the library functionality and the overhead would be less significant because any compiler would have to link in the same functionality in any case.

      You really are sweating the small stuff. If you really want to compare compilers fairly you must do it with a non-trivial amount of code. Unless that is your target applications are always trivial (as they might be if they were say simple utilities or batch command tools), then you may indeed be right in selecting a more appropriate tool for your target applications.

      Note that LCC is not free for commercial use - that may or may not be an issue for you.

      Clifford

       
    • Anonymous

      Anonymous - 2007-10-29

      There are several FAQ's on this subject.

      http://www.mingw.org/mingwfaq.shtml#faq-cpp-size
      http://www.bloodshed.net/faq.html#6
      http://www14.brinkster.com/aditsu/dev-cpp-faq.html#largeexe

      Each has a sligntly different view, but the solutions are the same.

      >> I had a look at the compiler/project settings and it didn't
      >> appear that any Debug stuff was turned on although I could be wrong
      To be sure look at the compile log. If you see that the compilation uses -g or -g3 you have debugging on. This is why you should always post the log!!!

      Clifford

       
    • Dave Turner

      Dave Turner - 2007-10-29

      Here is my compile log ...

      Compiler: Default compiler
      Building Makefile: "E:\Dev\DevCpp\Examples\Hello\Makefile.win"
      Executing make...
      make.exe -f "E:\Dev\DevCpp\Examples\Hello\Makefile.win" all
      g++.exe Hello2.o -o "Hello.exe" -L"E:/Dev/DevCpp/lib" -s

      Execution terminated
      Compilation successful
      --

      I dont see any -g or -g3 .... btw this is just the default install - I just installed dev-cpp and compiled Hello.cpp with default settings

       
    • merk6666

      merk6666 - 2007-10-30

      Dave, check the option "strip executable" (or smth similar) in linker options for the progect.
      and read the topic a bit below -
      "how to force dev-c to generate asm from c++?"
      problem was the same.
      it seems this "huge code" consists of symbolic info.

       
    • Dave Turner

      Dave Turner - 2007-10-30

      I don't have any debug options turned on ... I do have -s in my linker flags, I have Strip Executable set to true, but all that did was reduce it from 500k to 263kb, which again is still bloated considering all I'm doing is saying 'Hello world'

      Using lcc the same program can be accomplished in about 3kb. Using Powerbasic the same is about 7kb. Id imagine a Delphi exe would also be <50kb. So if another C compiler and even a basic compiler can make small exe's what's stopping me from doing the same in Bloodshed devcpp?
      urrgh, maybe I should just go back to lcc :( im getting nowhere fast with this

       
    • Wayne Keen

      Wayne Keen - 2007-10-30

      If the size of "Hello World" is an important metric than you, feel free to use another tool.
      A couple of points to ponder first.

      Please note that Dev-C++ is just an IDE. It is not the supplier of the compiler. The compiler
      is GCC, which works on Windows through the magic of another tool called MinGW.

      To make a long story short and semi-correct, the way that certaian standard libraries are
      licenced means that they can only be statically, not dynamically linked, which leads to code
      which uses C++ features such as iostreams being somewhat larger.

      This is a one time "charge" - the code I work with at work on a daily basis is 10's of thousands
      of lines long, and is still less than a megabyte in size.

      Again, if your metric is how big "Hello World" is - well, there's not much one can tell you.
      On the other hand, if you want to use a compiler to do some things somewhat more advanced, and
      don't worry about such things, then we are perfectly willing to abuse you some more.

      Keep in mind this is a free tool. No one here wants to "sell" you anything. Use what works best
      for you.

      Wayne

       

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.