There's no such thing as a stupid question, but they're the easiest to answer.
JoinTour
Login
 
Tag Cloud
access audio avg avg 8 bios blue screen boot bsod computer connection cpu crash css dell desktop dma driver drivers dvd email error excel explorer firefox firefox 3 freeze gimp graphics hard drive hardware hijackthis hjt install internet internet explorer itunes keyboard laptop macro malware monitor motherboard network networking outlook outlook 2003 outlook 2007 outlook express pio problem problems router seo server slow sound sp3 spyware trojan usb video virtumonde virus vista vundo windows windows vista windows xp winxp wireless
Software Development
Search
Search in:
 
Advanced Search
Tech Support Guy Forums > Software & Hardware > Software Development >
Bloodshed DevC++ Question


HELLO AND WELCOME! Before you can post your question, you'll have to register -- it's completely free! Click here to join today! We highly recommend that you print a copy of our Guide for New Members. Enjoy!

 
Thread Tools
blaqDeaph's Avatar
Senior Member with 860 posts.
 
Join Date: Nov 2005
Location: Down Under!
Experience: Enough
13-Dec-2005, 12:21 AM #1
Bloodshed DevC++ Question
Hi,

I just realized that for some reason, the files that are compiled by Bloodshed DevC++ are relativly huge. (500-700kb) for both Windows and DOS C++ projects . Any idea why this may be the case?
Shadow2531's Avatar
Distinguished Member with 2,629 posts.
 
Join Date: Apr 2001
13-Dec-2005, 02:05 AM #2
The compiler used by DevC++ Mingw, does things a little differently compared for VC++ for example.

When you include <iostream> for example so you can use cout, cin, cerr etc., you end up including a whole bunch of stuff. It doesn't matter if you actually use the stuff, you still take a file size hit.

For example:

Code:
#include <iostream>

int main() {

}
That will be 463KB with Mingw 3.4.2.
With VC++ 2003 toolkit, it'll be 21.5KB

For Mingw, one thing you can do is use the linker option -s to stripp all debugging info. That will shrink the file size in half a lot of the times. You can also use the -Os option to optimize for file size.

Besides that, there's not much you can do except pack the exe with upx.

For example, a command to compile file.cpp might look like this.

g++ -Wall -Wextra file.cpp -o file -Os -s && upx --best file.exe

That will usually bring your exe down to 80KB.

However, packing an exe means that it has to be unpacked in memory when you load it. This *could* decrease startup times of the app. (Although I've never seen it make a differerence.)

You can also avoid the STL and just use C methods, but that would defeat the purpose of using c++ methods.

If you look in the iostream file for mingw, you'll notice: static ios_base::Init __ioinit.

That call tells the linker to include everything needed to use cout etc.

Roughly, when you include <iostream>, it's like in your code, you're using everything Iostream supports. Other compilers only account for what you use.

The file size hit for mingw evens out as apps get bigger and to put simply, if you need to distribute an exe, zip it up or distribute it via an installer that uses good compression.

Just as another example, if you don't include <iostream>:

Code:
#include <cstdio>

int main() {

}
Mingw will compile that at 15KB and if you strip it, it'll be 5.5KB.
__________________
10 ? "a line as the unending horizon"
20 ? "a curve as the rolling hillside"
30 ? "a point as a distant bird"
40 ? "a ray as the rising sun"
run
blaqDeaph's Avatar
Senior Member with 860 posts.
 
Join Date: Nov 2005
Location: Down Under!
Experience: Enough
13-Dec-2005, 07:48 AM #3
Yea, I made a simple Hello World program, using <stdio.h> and <iostream.h>

stdio.h gave me 14.1kb normally, and 5.0kb stripped
iostream.h gave me 415kb normally, and 213kb stripped
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

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 Off
Refbacks are Off

You Are Using:
Server ID
Advertisements do not imply our endorsement of that product or service.
All times are GMT -4. The time now is 12:40 AM.
Copyright © 1996 - 2008 TechGuy, Inc. All rights reserved.
Powered by vBulletin, Copyright © 2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Powered by Cermak Technologies, Inc.