Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Developer Center > C vs C++ compiled binary sizes

C vs C++ compiled binary sizes
Thread Tools
Fresh-Faced Recruit
Join Date: Mar 2004
Status: Offline
Reply With Quote
Oct 19, 2004, 10:36 AM
 
Hi there,

I have decided to take up C/C++ programming as a hobby and starting at the Darwin command line I am getting to grips with GCC/G++.

Using the simple "Hello world" program, I have noticed that if written in C and compiled with GCC I get a binary size of about ~11Kb.

When I write that same program in C++ (using IOSTREAM) and compile with G++ I get a 660Kb binary!!

If I use "strip" this halves the binary size. I wonder if any of you Dev's can offer a bit of guidance as to why this is please? If I try the same example under Fedora Linux on my PC I get a binary sizes ~11K for each.

Thanks for your time
     
Mac Elite
Join Date: Dec 1999
Location: Plainview, NY
Status: Offline
Reply With Quote
Oct 19, 2004, 07:34 PM
 
     
Fresh-Faced Recruit
Join Date: Mar 2004
Status: Offline
Reply With Quote
Oct 21, 2004, 02:20 AM
 
Search is indeed my friend - thank you.

Seems that the large binaries are due to the static nature of libraries. I wonder if this may be remedied in future builds of the GCC environment?
     
Addicted to MacNN
Join Date: Mar 2000
Location: London, UK
Status: Offline
Reply With Quote
Oct 21, 2004, 01:59 PM
 
Originally posted by Tom Bombadil:
Seems that the large binaries are due to the static nature of libraries. I wonder if this may be remedied in future builds of the GCC environment?
I somewhat doubt that. The standard C++ library should be static for obvious reasons.

C++ is a big ugly beast. 600k isn't really that big in this day and age.
     
   
Thread Tools
Forum Links
Forum 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
Top
Privacy Policy
All times are GMT -5. The time now is 09:17 PM.
All contents of these forums © 1995-2011 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.7 © 2000-2011, Jelsoft Enterprises Ltd., Content Relevant URLs by vBSEO 3.3.2