Author Topic: Making smaller wxWidget binaries  (Read 3481 times)

TTIelu

  • Guest
Making smaller wxWidget binaries
« on: April 13, 2006, 01:32:58 pm »
Hello code::blocks community!

I am trying to develop a simple wxWidgets program, using STATIC linking. I dont like to send along 10MB of dll's with my application. Though when i compile, my binary hits 3,98MB. Using the compiler optimization options i can reduce it to 2,23MB. I wanne get my binary under the 1mb mark, especially since it is just the default example at this time.

I know the size of the binary comes from the linker, which includes the whole wxWidget library, but is it possible to only include the parts used by the application? Or any other way to reduce the size significantly?

Thank you in advance!
TTIelu

Offline mandrav

  • Project Leader
  • Administrator
  • Lives here!
  • *****
  • Posts: 4315
    • Code::Blocks IDE
Re: Making smaller wxWidget binaries
« Reply #1 on: April 13, 2006, 01:46:51 pm »
If you care about the executable size, try UPX.
Be patient!
This bug will be fixed soon...

Offline thomas

  • Administrator
  • Lives here!
  • *****
  • Posts: 3979
Re: Making smaller wxWidget binaries
« Reply #2 on: April 13, 2006, 02:03:07 pm »
You can also use a non-monolithic, static build and only link to the bare minimum set of libraries. That will include significantly less code (if you don't use most of wxWidgets), but it is also significantly more maintenance work.

Also, you can edit setup.h and disable everything that you don't need (image loading, joysticks,... whatever). This is even more maintenance work and you can quite easily break something.

Both "solutions" (if you want to call them solutions) require recompiling wxWidgets.

Finally, you can also use a different linker (and/or compiler). UltimateCPP is said to have a custom, significantly better linker compatible to gcc. In my experience, it is none better, but during ~20 builds, it crashed twice (after that, I removed it).
There is yet another ld replacement whose name I forgot, but I think it was mainly optimized for link speed.
The DM and MS compilers produce significantly smaller wxWidgets libraries. If size is all that matters, you should try those.
Personally, I don't think it matters at all any more. A few years ago, I was very concerned about such things as executable size, but big M is notorious about wasting resources in the most outrageous way, and consequently both storage and bandwidth have become a lot cheaper to the end user ;)
I mean, look around, you will hardly find a PC with less than a 3-digit Gigabyte hard disk space, and very few users actually have less than 1-2 MBits/s network connection.

If you are concerned about repeatedly uploading to a FTP server or something, you may want to try rsync or bsdiff or anything like that. Depending on what you do, those work wonders :)
"We should forget about small efficiencies, say about 97% of the time: Premature quotation is the root of public humiliation."

TTIelu

  • Guest
Re: Making smaller wxWidget binaries
« Reply #3 on: April 13, 2006, 02:08:51 pm »
Thank you both for the tips, i will try em out. The upx method seems to work quite fine reducing my binary to +-1/3'th its size.

Offline squizzz

  • Almost regular
  • **
  • Posts: 132
« Last Edit: April 13, 2006, 02:16:37 pm by squizzz »
this space is for rent