Small executables in VC++ 8

This is a discussion on Small executables in VC++ 8 within the Windows Programming forums, part of the Platform Specific Boards category; Does anyone know of any tutorials around, or have any tips on creating small executables with VC++ 8? There are ...

  1. #1
    Madly in anger with you
    Join Date
    Nov 2005
    Posts
    211

    Small executables in VC++ 8

    Does anyone know of any tutorials around, or have any tips on creating small executables with VC++ 8? There are several tutorials around, but alot of the techniques used only apply to VC++ 6 (and the ones that still work don't seem to make any significant differences). The smallest executable I've produced with VC++ 8 was 3.5KB, when I statically linked the CRT (probably smaller than dynamically linking as I barely used any of the C standard library). I believe the smallest executable I've produced with VC++ 6 was 2KB, without manipulating anything manually such as a custom DOS stub, etc.

    When I open up executables produced with VC++ 8 in a hex editor I see stuff such as embedded manifests and a whole lot of padding. I don't see why the manifests are necessary in things such as console apps, so I'm wondering if it's possible to cut stuff like this out of final builds. I probably can't do much about the padding, but I don't see the purpose of the manifests.

    I know alot of people are probably thinking that I shouldn't be so fussy on size, but why not. I try to write the tightest code I can, and it's rewarding to see such small executables I've written performing so much work so quickly. What's not rewarding is writing such tight code and then watching as your compiler bloats it out with nonsense. It's kinda like a spit in the face.

    Could anyone here please point me to tutorials or give me some tips on creating small executables with VC++ 8?


    Thanks.

    Intel Core 2 Quad Q6600 @ 2.40 GHz
    3072 MB PC2-5300 DDR2
    2 x 320 GB SATA (640 GB)
    NVIDIA GeForce 8400GS 256 MB PCI-E

  2. #2
    Registered Abuser
    Join Date
    Jun 2006
    Location
    Toronto
    Posts
    591
    Quote Originally Posted by sl34k View Post
    ...I know alot of people are probably thinking that I shouldn't be so fussy on size, but why not. I try to write the tightest code I can, and it's rewarding to see such small executables I've written performing so much work so quickly. What's not rewarding is writing such tight code and then watching as your compiler bloats it out with nonsense. It's kinda like a spit in the face....
    I don't think "tight code" and "VC++" belong in the same sentence. If you're looking for better optimization I suggest using gcc/MingW with the "-Os" option. You don't even really need VC++ unless you're doing some really intense Windows programming (such as MFC), in which case, executable size would be the least of your "effeciency" problems.

  3. #3
    Registered User Joelito's Avatar
    Join Date
    Mar 2005
    Location
    Tijuana, BC, México
    Posts
    308
    The only think that I hate from gcc/MingW is the direct link to msvcrt.dll
    * PC: Intel Core 2 DUO E6550 @ 2.33 GHz with 2 GB RAM: Archlinux-i686 with xfce4.
    * Laptop: Intel Core 2 DUO T6600 @ 2.20 GHz with 4 GB RAM: Archlinux-x86-64 with xfce4.

  4. #4
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,498
    http://msdn2.microsoft.com/en-us/lib...t4(VS.80).aspx
    Such options as /ALIGN, /SECTION, /MERGE, /OPT all seem capable of messing about with the size of the executable by for example eliminating all the dead space between sections.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. how to split long programe in small files
    By umeshjaviya in forum C Programming
    Replies: 11
    Last Post: 04-15-2008, 02:45 AM
  2. Creating small executables
    By cloudy in forum C++ Programming
    Replies: 8
    Last Post: 05-25-2006, 01:17 PM
  3. FILES in WinAPI
    By Garfield in forum Windows Programming
    Replies: 46
    Last Post: 10-02-2003, 06:51 PM
  4. STL + MSVC++ = big executables ?
    By teneniel in forum C++ Programming
    Replies: 6
    Last Post: 11-04-2002, 01:12 PM
  5. yhatzee, small straight
    By uglyjack in forum C++ Programming
    Replies: 2
    Last Post: 06-13-2002, 03:09 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21