Welcome to the most active Linux Forum on the web.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!


  Search this Thread
Old 06-19-2012, 03:47 PM   #1
Senior Member
Registered: Dec 2005
Location: Florida
Distribution: CentOS/Fedora
Posts: 2,630

Rep: Reputation: 495Reputation: 495Reputation: 495Reputation: 495Reputation: 495
fast question about C

I am reading "The C Programing Langues ANSI C" by Brian W. Kernighan and Dennis M. Ritchie (2nd edition) and working my way through the beginner scripts.

I notice that after i gcc foo.c -o foo.out that the size difference is much larger then I would have expected for something that is now written in "computer" langue for lack of a better term.

[xxxx@xxxx backup]$ ls -laF count*
-rw-rw-r-- 1 xxxx xxxx  170 Jun 13 10:39 count.c
-rwxrwxr-x 1 xxxx xxxx 5041 Jun 13 10:39 count.out*
Why is this, what am I missing?
Old 06-19-2012, 04:06 PM   #2
Senior Member
Registered: Oct 2003
Location: Bonaire
Distribution: Debian Wheezy/Jessie/Sid, Linux Mint DE
Posts: 4,501

Rep: Reputation: 636Reputation: 636Reputation: 636Reputation: 636Reputation: 636Reputation: 636
The size has increased because standard libraries (like I/O) have been linked in.

Old 06-19-2012, 04:10 PM   #3
Registered: Mar 2011
Location: Rome - Italy
Distribution: Slackware 13.1
Posts: 347

Rep: Reputation: 44
It can depend on how many includes are in the source, on the fact that the compiled program has much more machine instruction than you expect and it can increase a lot its size if you compile static libraries in it!
To reduce the size of your binary file you can strip it with the strip command.
Old 06-19-2012, 04:13 PM   #4
Senior Member
Registered: Dec 2005
Location: Florida
Distribution: CentOS/Fedora
Posts: 2,630

Original Poster
Rep: Reputation: 495Reputation: 495Reputation: 495Reputation: 495Reputation: 495
thank you both, that makes sense.

Slackyman, ill read the man strip page to learn about that.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
n00b question, Need help fast 27307SB Programming 7 09-21-2005 04:20 AM
Fast Question: SWAP-file in Ubuntu disabled by default? Waerner Ubuntu 2 07-14-2005 09:57 AM
Stupid question, fast switching languages gljubuncic Linux - Software 1 05-29-2005 05:49 PM
/etc/inittab fast question Lleb_KCir Linux - Software 3 12-02-2004 02:39 PM
simple video driver question - need help fast dmarotto Linux - General 3 02-15-2004 12:20 PM

All times are GMT -5. The time now is 04:24 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration