Jump to content
View in the app

A better way to browse. Learn more.

Tuts 4 You

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Reduce your C++ executable size

Featured Replies

Posted

Hello All,

I wrote a little paper about reducing the file size of a cpp project. Covers some basic stuff like removing cruntime, merging sections etc.. Hope it helps someone and of course if you have improvements, other techniques or found bugs then feel free to write me.

~Zer0Flag

Decrease_WinCppProject_FileSize.pdf

A good work, very detailed

Thank you

I have bookmarked this thread: http://forum.tuts4you.com/topic/20209-msvc2008-removing-msvc-framework-code/

There is some more information.

What I learned: Using "pragma"s to tweak the output file is much better, because you can combine it with DEFINES. You can fast switch it on or off -> useful for debugging because sometimes this causes some problems.

Just a heads up with your PDF; the option to choose between Multithreaded-DLL and Multithreaded are not present in Express editions of Visual Studio. This is a non-free feature that is only present in the paid versions.

Your us /O1 or /O2 i see but if your us /Oxs=Full optimation + small code it makes the result are littel bit more smaller.

If your us the command line tools like (cl,link,lib) your can make the result very small.

Her an bsp:


cl /c /Oxs /W3 mrcore.c
cl /c /Oxs /W3 mrarth0.c
cl /c /Oxs /W3 mrarth1.c
cl /c /Oxs /W3 mrarth2.c
cl /c /Oxs /W3 mralloc.c
cl /c /Oxs /W3 mrsmall.c
cl /c /Oxs /W3 mrio1.c
cl /c /Oxs /W3 mrio2.c
cl /c /Oxs /W3 mrgcd.c
cl /c /Oxs /W3 mrjack.c
cl /c /Oxs /W3 mrxgcd.c
cl /c /Oxs /W3 mrarth3.c
cl /c /Oxs /W3 mrbits.c
cl /c /Oxs /W3 mrrand.c
cl /c /Oxs /W3 mrprime.c
cl /c /Oxs /W3 mrcrt.c
cl /c /Oxs /W3 mrscrt.c
cl /c /Oxs /W3 mrmonty.c
cl /c /Oxs /W3 mrpower.c
cl /c /Oxs /W3 mrsroot.c
cl /c /Oxs /W3 mrcurve.c
cl /c /Oxs /W3 mrfast.c
cl /c /Oxs /W3 mrlucas.c
cl /c /Oxs /W3 mrzzn2.c
cl /c /Oxs /W3 mrzzn2b.c
cl /c /Oxs /W3 mrzzn3.c
cl /c /Oxs /W3 mrzzn4.c
cl /c /Oxs /W3 mrshs.c
cl /c /Oxs /W3 mrshs256.c
cl /c /Oxs /W3 mrshs512.c
cl /c /Oxs /W3 mraes.c
cl /c /Oxs /W3 mrgcm.c
cl /c /Oxs /W3 mrstrong.c
cl /c /Oxs /W3 mrbrick.c
cl /c /Oxs /W3 mrebrick.c
cl /c /Oxs /W3 mrgf2m.c
cl /c /Oxs /W3 mrec2m.c
cl /c /Oxs /W3 mrecn2.c
cl /c /Oxs /W3 mrflash.c
cl /c /Oxs /W3 mrfrnd.c
cl /c /Oxs /W3 mrdouble.c
cl /c /Oxs /W3 mrround.c
cl /c /Oxs /W3 mrbuild.c
cl /c /Oxs /W3 mrflsh1.c
cl /c /Oxs /W3 mrpi.c
cl /c /Oxs /W3 mrflsh2.c
cl /c /Oxs /W3 mrflsh3.c
cl /c /Oxs /W3 mrflsh4.c
cl /c /Oxs /W3 mrkcm.c
cl /c /Oxs /W3 mrcomba2.c
copy mrmuldv.w64 mrmuldv.c
cl /c /Oxs /W3 mrmuldv.c

The result for this is about 361kb for the lib.

If your make the same with vc with out the command line tools your get for the same lib this result:

1 - 2 mb

I had been working on a tutorial for this very subject for a couple weeks now, and after seeing your article (which is very good, btw) I decided to finish mine. It is more detailed than yours (I wanted to see how the various options affected the actual disassembly in OllyDBG) and the pictures have been translated to English. Hope you enjoy...


/>http://thelegendofrandom.com/blog/archives/2231

@Zer0Flag

Thanx for this excellent tutorial.

Will test in detail.

Btw. did yu test to use crinkler with the shrinked exe?

  • Author

@hmi222

Thanks, no I didn´t test any packer to see if it get even smaller. Since the goal of this was to show how you can decrease the file size using compiler and linker settings. But you can use ASM to shrink it until you reach 92bytes or something. If you are interested in this you should take a look in google for "tiny pe".

~Zer0Flag

Create an account or sign in to comment

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.