Guidance
指路人
g.yi.org
Guidance Forums / wxWidgets (wxWindows) in C++ / Porting & How do you make your output file smaller?

Register 
注册
Search 搜索
首页 
Home Home
Software
Upload

  
Forum List • Thread List • Reply • Refresh • New Topic • Search • Previous • Next First 1 Last
Message1. Porting & How do you make your output file smaller?
#3361
Posted by: 2004-02-13 09:21:23
I have 2 questions:

1. I've been writing a program for my school on my computer, which runs WinXP.  When I put my wxWindows program on my school's computers, which run Win95, I get an error about a missing MSVCRT.dll file.  Is there any way I can fix this problem without manually supplying the DLL?

2. I noticed that my wxWindows program was a whole 2MB, even though I only had about 200 or so lines in it.  Is there anyway I can make the output file smaller?  (In case this is solved by editing the linker options, I included my linker options below)

[C++ Compiler]
-DWINVER=0x0400 -D__WIN95__ -D__GNUWIN32__ -D__WIN32__ -DHAVE_W32API_H  -D__WXMSW__ -D__WINDOWS__ -Wall -fno-pcc-struct-return -O2 -Os -fno-rtti -fno-exceptions

[Linker]
-Wl,--subsystem,windows -mwindows -lwxmsw -lstdc++ -lgcc -lodbc32 -lwsock32 -lwinspool -lwinmm -lshell32 -lcomctl32 -lctl3d32 -ladvapi32 -lopengl32 -lglu32 -lole32 -loleaut32 -luuid 
-ltiff
-lpng
-ljpeg
-lz

-Includes-
#include <wx/window.h>
#include <wx/image.h>
#include <wx/splash.h>
#include <wx/bitmap.h>
#include <wx/filedlg.h>
#include <wx/msgdlg.h>
#include <wx/event.h>
#include <wx/textfile.h>
#include <wx/dcclient.h>
#include <wx/panel.h>


Thanks in advance =)
Message2. Re: Porting & How do you make your output file smaller?
#3362
Posted by: guidance 2004-02-13 17:59:38
http://g.yi.org/f.php?f=4628
Message3. Re: Porting & How do you make your output file smaller?
#3365
Posted by: upCASE 2004-02-13 22:31:59
Hi!
1. I guess you'll be out of luck if you don't want to supply this dll. Problem is that mingw gcc links to this DLL, because it uses the standard C runtime MS provided with it. Win98 and higher versions do have this DLL by standard, for Win95 you either need to supply it or get an official MS update. Simply install the DLL in WINDIRsystem and you're done with.

2. Yes, compiled with gcc wxWindows apps get pretty big compared to apps compiled with MS VC++. The reason for that is that gcc (or g++) has to provide it's own C++ runtime and link it in. C++ produces some overhead. With upcoming versions this may change. gcc 3.3.1 produces smaller apps.
You have a few options.
- Strip the app. Do so be either using strip exename.exe on the command line or using the -s option in your linker settings.
- Use upx. It's a free exe packer that reduces size normaly about 30%-35%.
- Compile wxWindows as a DLL. That way you'll have to provide the DLL with your app, but the app itself will be small.

upCASE
-----------------------------------
If it was hard to write, it should be hard to read!- Do. Or do not. There is no try!
Message4. Thanks
#3366
Posted by: 2004-02-14 01:04:20
Thanks Guidance and upCASE.

Guidancem, I copied your compiler and linker settings, and that reduced the file size from 2.04MB to 0.98MB!  And I took your advice, upCASE, with using the exe packer (as well as the strip idea), and it reduced the file from 0.98MB to 356KB!  I never thought an exe packer compressed the file that much.
Forum List • Thread List • Reply • Refresh • New Topic • Search • Previous • Next First 1 Last
掌柜推荐
 
 
 
 
 
 
 
 
 
 
 
 
© Thu 2024-10-3  Guidance Laboratory Inc.
Email:webmaster1g.yi.org Hits:0