Code Newbie
News     Forums     Search     Members     Sign Up    

My Code Newbie
Username

Password

Articles/Snippets
ASP Classic
ASP.NET
C
C#
C++
HTML / CSS
Java
Javascript
Linux / BSD
Perl
PHP
Python
Ruby
SQL
VB 6
VB.NET

C.N. Friends
  Planet Rome

Link to Us!
Code Newbie
  Code Newbie
    forums
Old 03-22-2003, 02:35 PM   #1 (permalink)
Danish
Registered User
 
Join Date: Mar 2003
Posts: 12
Danish is on a distinguished road
Send a message via AIM to Danish
How to make smaller files with MinGW tools

Edit: Alright, I figured out how to make my files smaller in MinGW. If your MinGW compiled files are 90kb bigger than they should be, (like a hello, world project in C takes up 96kb instead of 4) and you don't know why, just take a look at my next post.

Oh, if you use iostream to do your console i/o, expect your file to be 200kB anyway (it'd be 400-some otherwise, but past using -s you won't see too awfully much of a difference. Moral, for those that have only learned C++ in school: if you're only outputting to the screen, and you aren't using any fancy cout manipulation or overloading, just use printf())

Original message:

I can't seem to be able to make my linked files very small using MinGW? My objects are 2kB, but the outputted executible is 96kB, 52kB stripped, and 24kB UPXed. I'm using a tutorial, and the executible that came with it is only 4kB (3072 bytes UPXed). This is just for a simple window that can be resized and closed. What am I missing? Thanks for lookin'.]
Danish is offline   Reply With Quote
Old 03-22-2003, 10:43 PM   #2 (permalink)
Danish
Registered User
 
Join Date: Mar 2003
Posts: 12
Danish is on a distinguished road
Send a message via AIM to Danish
Fixed.

Fixed my own problem, I believe. When I do this:

gcc foo.o -s -fno-exceptions -fno-rtti -ofoo

I get much smaller code than before. Got the info from here: http://www.spacejack.org/games/mingw/

Edit: Okay, so that was a general command that wouldn't work in real life. Here's a better example or two:

g++ foo.cc -s -fno-exceptions -fno-rtti -ofoo
gcc foo.c -s -fno-exceptions -ofoo
Danish is offline   Reply With Quote
Old 03-24-2003, 07:38 AM   #3 (permalink)
devin
Registered User
 
Join Date: Mar 2003
Location: California
Posts: 9
devin is on a distinguished road
Send a message via ICQ to devin
Hey Danish,

I have been using MinGW for a while and also wondered why the executables created were so large. I actually thought that this was because g++ wasn't that great of an optimizing compiler..

Thank you for the tips and link.
devin is offline   Reply With Quote
Old 03-24-2003, 09:04 AM   #4 (permalink)
Valmont
[code][/code] enforcer
 
Valmont's Avatar
 
Join Date: Mar 2003
Location: Netherlands
Posts: 1,545
Valmont is on a distinguished road
Many compilers have an armada of optional commands to tweak the executable.
Valmont is offline   Reply With Quote
Old 03-24-2003, 10:07 AM   #5 (permalink)
Danish
Registered User
 
Join Date: Mar 2003
Posts: 12
Danish is on a distinguished road
Send a message via AIM to Danish
Quote:
Originally posted by devin
Hey Danish,

I have been using MinGW for a while and also wondered why the executables created were so large. I actually thought that this was because g++ wasn't that great of an optimizing compiler..

Thank you for the tips and link.
Yeah, me, too, but when I saw that many people's compiled files were so much smaller than mine, I decided to investigate. I should have seen it straight off, really -- if you compile without those options, your executible is flooded with a myriad of exception handling and other strings (the last few kb of text in each executible, and a lot of object code in between).

I'll also change the topic of this post so that people won't look over it that would find it helpful.

- Dane
Danish is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -8. The time now is 12:12 AM.


Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.0.0 RC8





Copyright © 2000-2008, Milano Interactive
Web Hosting provided by Portal 360 Web Hosting