LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
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!

Notices


Reply
  Search this Thread
Old 06-19-2012, 04:47 PM   #1
lleb
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.

Code:
[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, 05:06 PM   #2
jlinkels
Senior Member
 
Registered: Oct 2003
Location: Bonaire
Distribution: Debian Wheezy/Jessie/Sid, Linux Mint DE
Posts: 4,493

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

jlinkels
 
Old 06-19-2012, 05:10 PM   #3
Slackyman
Member
 
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, 05:13 PM   #4
lleb
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.
 
  


Reply


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 05:20 AM
Fast Question: SWAP-file in Ubuntu disabled by default? Waerner Ubuntu 2 07-14-2005 10:57 AM
Stupid question, fast switching languages gljubuncic Linux - Software 1 05-29-2005 06:49 PM
/etc/inittab fast question Lleb_KCir Linux - Software 3 12-02-2004 03:39 PM
simple video driver question - need help fast dmarotto Linux - General 3 02-15-2004 01:20 PM


All times are GMT -5. The time now is 02:38 AM.

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