|
From: <or...@vp...> - 2003-06-09 16:13:30
|
Glen Vermeylen wrote: > I noticed my programs are always quite large: > 22.4 kb for an "empty" project, 439 for the standard console application > and I'm instantly at 2mb when using wxWindows. > How can I reduce these sizes? Hehe. 22.4 KB is acceptable, and it won't rise much for simple C console apps. 439 KB is due to the usage of C++ iostream. It introduces huge bloat, which cannot be avoided, only by NOT using it, just simple C I/O (printf and such). Decide yourself what to do. 2MB with wxWindows is due to the fact, that you link statically with wxWindows. A solution would be to use the DLL form of wxwindows, but as far as I know, the DevPak does not contain the wxwindows DLL, nor the import library for it. With the DLL, the size would only be a mere 200 KB or so. Note, that either case, it is unlikely that the program size will increase any further. For all cases, exe size reduction can be achieved, by stripping them. Either supply the -s flag for the *linker*, or type "strip <prog>.exe" at a command prompt (replacing <prog> with your program's name). strip can be found in the bin directory of the MinGW compiler. Other solution might be to use level 4 optimization (-O4) and disabling any sort of debug generation (-g0), which is by default disabled I think (not sure). Specify these for the *compiler*. Another solution is to use an exe compressor. I *highly* recommend UPX, the Ultimate Packer for eXecutables. It is open-source, and very high performance, without *ANY* program speed loss. Visit http://upx.sf.net for details. Download it, place it into a directory, which is accessible from a command prompt (i.e. add that dir to the PATH environment variable), then use this command for best compression: upx -9 <program>.exe With all the above methods I was able to reduce a 2,3 MB wxWindows executable to 427 KB. I hope that helps. Good luck. -- Greetings, Balázs |