Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » Community » Newbie corner » Is there any trick to reduce the executable even further?
Is there any trick to reduce the executable even further? [message #39074] Tue, 12 February 2013 18:01 Go to next message
lectus is currently offline  lectus
Messages: 329
Registered: September 2006
Location: Brazil
Senior Member
Besides using MSVC++ optimized for size.

What else can be done?
Re: Is there any trick to reduce the executable even further? [message #39076 is a reply to message #39074] Tue, 12 February 2013 18:45 Go to previous messageGo to next message
dolik.rce is currently offline  dolik.rce
Messages: 1758
Registered: August 2008
Location: Czech Republic
Senior Contributor

lectus wrote on Tue, 12 February 2013 18:01

Besides using MSVC++ optimized for size.

What else can be done?


Perhaps executable compression.

May I ask what is the reason why you need to reduce the size of executable? Also, what kind of executable? There sure will be different approach for simple console utility and for full-blown GUI app...

Best regards,
Honza

[Updated on: Tue, 12 February 2013 18:46]

Report message to a moderator

Re: Is there any trick to reduce the executable even further? [message #39080 is a reply to message #39074] Wed, 13 February 2013 17:25 Go to previous messageGo to next message
chickenk is currently offline  chickenk
Messages: 168
Registered: May 2007
Location: Grenoble, France
Experienced Member
Using gcc, I would use the following:
CFLAGS = -Os -ffunction-sections -fdata-sections
CXXFLAGS = -Os -ffunction-sections -fdata-sections
LDFLAGS = -Os -Wl,--gc-sections

If you are creating ELF executables, you can also try superstrip: http://www.skarnet.org/software/misc/superstrip.c

My 2 cents...
Lionel
Re: Is there any trick to reduce the executable even further? [message #39081 is a reply to message #39074] Wed, 13 February 2013 19:42 Go to previous messageGo to next message
Novo is currently offline  Novo
Messages: 893
Registered: December 2006
Experienced Contributor
lectus wrote on Tue, 12 February 2013 12:01

Besides using MSVC++ optimized for size.

What else can be done?


You can take a look at places where your code came from using this tool. (You will need to enable map file generation in VS for that). May be this will give you new optimization ideas.


Regards,
Novo
Re: Is there any trick to reduce the executable even further? [message #39086 is a reply to message #39080] Thu, 14 February 2013 15:17 Go to previous messageGo to next message
lectus is currently offline  lectus
Messages: 329
Registered: September 2006
Location: Brazil
Senior Member
chickenk wrote on Wed, 13 February 2013 11:25

Using gcc, I would use the following:
CFLAGS = -Os -ffunction-sections -fdata-sections
CXXFLAGS = -Os -ffunction-sections -fdata-sections
LDFLAGS = -Os -Wl,--gc-sections

If you are creating ELF executables, you can also try superstrip: http://www.skarnet.org/software/misc/superstrip.c

My 2 cents...
Lionel



Interesting, but with -fdata-sections Mingw creates a BIGGER executable for me.

It adds an extra .data section in the executable.
Re: Is there any trick to reduce the executable even further? [message #39087 is a reply to message #39076] Thu, 14 February 2013 15:44 Go to previous messageGo to next message
lectus is currently offline  lectus
Messages: 329
Registered: September 2006
Location: Brazil
Senior Member
dolik.rce wrote on Tue, 12 February 2013 12:45

lectus wrote on Tue, 12 February 2013 18:01

Besides using MSVC++ optimized for size.

What else can be done?


Perhaps executable compression.

May I ask what is the reason why you need to reduce the size of executable? Also, what kind of executable? There sure will be different approach for simple console utility and for full-blown GUI app...

Best regards,
Honza


Yeah. I'm aware of UPX.

The reason is: I just like to deliver the best features in the smallest size possible. (btw... U++ is already great for that compared to other toolkits)
Re: Is there any trick to reduce the executable even further? [message #39088 is a reply to message #39074] Thu, 14 February 2013 16:09 Go to previous messageGo to next message
lectus is currently offline  lectus
Messages: 329
Registered: September 2006
Location: Brazil
Senior Member
My best results:
424kb with VC++ 2010, release, optimize for size, all static, packed with UPX

If I leave MVC++ 2010 runtime library as DLL I get: 359kb

Quite good if I'm distributing more than one application and the user has this package installed: http://www.microsoft.com/en-us/download/details.aspx?id=5555
Re: Is there any trick to reduce the executable even further? [message #39089 is a reply to message #39074] Thu, 14 February 2013 19:30 Go to previous messageGo to next message
lectus is currently offline  lectus
Messages: 329
Registered: September 2006
Location: Brazil
Senior Member
Update:

Found this awesome tool: http://www.jrsoftware.org/striprlc.php

Got the size down from 1043968 to 956416 bytes without compression.

This tool removes the .reloc section that is absolutely useless in EXEs (useful only in DLLs).
Re: Is there any trick to reduce the executable even further? [message #39091 is a reply to message #39089] Thu, 14 February 2013 19:53 Go to previous messageGo to next message
Novo is currently offline  Novo
Messages: 893
Registered: December 2006
Experienced Contributor
lectus wrote on Thu, 14 February 2013 13:30

This tool removes the .reloc section that is absolutely useless in EXEs (useful only in DLLs).


If ASLR is enabled either directly by Windows or by a third party tool you can get into trouble.


Regards,
Novo
Re: Is there any trick to reduce the executable even further? [message #39092 is a reply to message #39091] Thu, 14 February 2013 20:04 Go to previous messageGo to next message
lectus is currently offline  lectus
Messages: 329
Registered: September 2006
Location: Brazil
Senior Member
Novo wrote on Thu, 14 February 2013 13:53

lectus wrote on Thu, 14 February 2013 13:30

This tool removes the .reloc section that is absolutely useless in EXEs (useful only in DLLs).


If ASLR is enabled either directly by Windows or by a third party tool you can get into trouble.


It seems I'd need to link against ASLR for it to be an issue.
Re: Is there any trick to reduce the executable even further? [message #39095 is a reply to message #39092] Thu, 14 February 2013 20:13 Go to previous messageGo to next message
Novo is currently offline  Novo
Messages: 893
Registered: December 2006
Experienced Contributor
lectus wrote on Thu, 14 February 2013 14:04

Novo wrote on Thu, 14 February 2013 13:53

lectus wrote on Thu, 14 February 2013 13:30

This tool removes the .reloc section that is absolutely useless in EXEs (useful only in DLLs).


If ASLR is enabled either directly by Windows or by a third party tool you can get into trouble.


It seems I'd need to link against ASLR for it to be an issue.


IMHO, ASLR is a part of a loader, which is a part of Windows (this is not the case in Unix). You do not link against ASLR. Loader just loads your app at random address. You need to do something to your app to tell loader that you want to load it at random address (most likely this is a flag), but there are third party tools, and nobody knows what will happen after another Windows update. Smile


Regards,
Novo
Re: Is there any trick to reduce the executable even further? [message #39096 is a reply to message #39074] Thu, 14 February 2013 20:16 Go to previous messageGo to next message
Novo is currently offline  Novo
Messages: 893
Registered: December 2006
Experienced Contributor
lectus wrote on Tue, 12 February 2013 12:01

Besides using MSVC++ optimized for size.

What else can be done?


Use MSVC 9 (2008).
http://www.ultimatepp.org/forum/index.php?t=rview&goto=3 9093


Regards,
Novo

[Updated on: Thu, 14 February 2013 20:17]

Report message to a moderator

Re: Is there any trick to reduce the executable even further? [message #39124 is a reply to message #39074] Sat, 16 February 2013 21:54 Go to previous message
nlneilson is currently offline  nlneilson
Messages: 644
Registered: January 2010
Location: U.S. California. Mojave &...
Contributor
lectus: Just curious about your concern of size.

I was several years ago but optimizing code and error handling seems to concern me now and size is almost irrelevant.

I guess the 'app stores' have a size limit, is that it?
Previous Topic: Compiling a U++ project with a Python API on Windows
Next Topic: Per file compile flags
Goto Forum:
  


Current Time: Mon Dec 16 01:23:34 CET 2019

Total time taken to generate the page: 0.02312 seconds