LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
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, 03:47 PM   #1
lleb
Senior Member
 
Registered: Dec 2005
Location: Florida
Distribution: CentOS/Fedora/Pop!_OS
Posts: 2,983

Rep: Reputation: 551Reputation: 551Reputation: 551Reputation: 551Reputation: 551Reputation: 551
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, 04:06 PM   #2
jlinkels
LQ Guru
 
Registered: Oct 2003
Location: Bonaire, Leeuwarden
Distribution: Debian /Jessie/Stretch/Sid, Linux Mint DE
Posts: 5,195

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

jlinkels
 
Old 06-19-2012, 04: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, 04:13 PM   #4
lleb
Senior Member
 
Registered: Dec 2005
Location: Florida
Distribution: CentOS/Fedora/Pop!_OS
Posts: 2,983

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

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


Reply



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

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 09:32 PM.

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
Open Source Consulting | Domain Registration