LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
Search this Thread
Old 09-22-2009, 03:41 PM   #1
Lawand
LQ Newbie
 
Registered: Sep 2009
Location: Damascus
Distribution: xubuntu
Posts: 4

Rep: Reputation: 1
How can an object file be executed without startup and housekeeping?


I came from Windows and I am want to learn how C++ programs are compiled and executed in Linux.
I read in "Thinking in C++" that the linker adds (by default) a startup module to the object files that an application should be made of.
Now when I use g++, I can create an single object module out of a single source code file then execute it in the terminal like this:
./objectFile.out

How can this object file be executed while it doesn't contain the startup module?
In Windows, object files usually get combined into an executable file (somthing.exe) then that executable can be executed, is this not necessary in Linux? does the OS perform required actions before it executes that object file?

Thanks in advance.
 
Old 09-22-2009, 05:54 PM   #2
smeezekitty
Senior Member
 
Registered: Sep 2009
Location: Washington U.S.
Distribution: M$ Windows / Debian / Ubuntu / DSL / many others
Posts: 2,227

Rep: Reputation: 170Reputation: 170
because you didnt compile it to an object file
you compiled it to an full exeicutable
gcc -c source.c -o output.out makes an object file
gcc source.c -o output.out makes a full program
 
Old 09-22-2009, 06:16 PM   #3
Lawand
LQ Newbie
 
Registered: Sep 2009
Location: Damascus
Distribution: xubuntu
Posts: 4

Original Poster
Rep: Reputation: 1
That's a great info.

Thanks mate.
 
Old 09-23-2009, 01:37 AM   #4
smeezekitty
Senior Member
 
Registered: Sep 2009
Location: Washington U.S.
Distribution: M$ Windows / Debian / Ubuntu / DSL / many others
Posts: 2,227

Rep: Reputation: 170Reputation: 170
your welcome
this forum tries to help people as much as possable
 
  


Reply

Tags
c++, programming


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
binary file not executed rakesh.n Programming 3 03-15-2009 11:52 PM
g++ compiles the file but a.out cannot be executed street_scientist Programming 9 07-31-2008 08:20 AM
wxPython problem: /_core_.so: cannot open shared object file: No such file or directo aregmi Linux - Software 2 06-06-2007 08:53 PM
libawt.so: libXp.so.6: cannot open shared object file: No such file or directory man26 *BSD 0 09-10-2004 08:34 AM
Simple script to be executed on startup. Korff Linux - General 2 06-03-2003 09:25 PM


All times are GMT -5. The time now is 07:31 PM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration