The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
.
google unix.com



UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
How can i read a non text file in unix - ELF-64 executable object file - IA64 alexcol UNIX for Advanced & Expert Users 8 11-07-2008 08:56 AM
What's The Easiest Route To Creating A Unix Executable File for Terminal? unimachead OS X (Apple) 10 11-03-2008 12:40 PM
Executable file tonet Shell Programming and Scripting 3 01-17-2008 12:03 PM
problem in creating executable for a client program konas High Level Programming 2 11-17-2006 02:09 PM
Newbie question about difference between executable file and ordinary file Balaji UNIX for Dummies Questions & Answers 1 11-29-2000 06:49 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 09-29-2007
compbug compbug is offline
Registered User
  
 

Join Date: Mar 2006
Posts: 26
creating executable for every C file

hello Folks,

once we compile any C code on Linux, we run the code using "./a.out"..

but can we have an executable for every program so that we can run the code directly without compiling the code every time.
just run the executable and get the output!

Thanks!
  #2 (permalink)  
Old 09-29-2007
porter porter is offline Forum Advisor  
Registered User
  
 

Join Date: Jan 2007
Posts: 2,965
You could do. Except that normally non-trival C programs are more than one source file.

You could write a C interpretor, but there is no real demand for them. The advantages you get from using C are mainly because it's a compiled language.

I rarely call my programs a.out, it would get far too confusing trying to remember which one did what.
  #3 (permalink)  
Old 09-29-2007
compbug compbug is offline
Registered User
  
 

Join Date: Mar 2006
Posts: 26
how could I do that?

well, how could I do that?
could you please explain?

I think it is better way to have an executable for all C codes.... atleast for the trial codes we run to understand the concepts!!

Thanks!
  #4 (permalink)  
Old 09-29-2007
porter porter is offline Forum Advisor  
Registered User
  
 

Join Date: Jan 2007
Posts: 2,965
I may be missing the point on your question but C is a compiled language.

To run it you have to:

(a) compile the C source into object files
(b) link the object files with libraries to produce the executable

once you have done that you can run the executable as many times as you like, and you can call it whatever name you like.

It is also compiled specific to the computer's architecture, so you can't expect 386 code to run natively on an UltraSparc. Similarly it is operating system dependent.
  #5 (permalink)  
Old 09-30-2007
Perderabo's Avatar
Perderabo Perderabo is offline Forum Staff  
Unix Daemon
  
 

Join Date: Aug 2001
Location: Ashburn, Virginia
Posts: 9,111
Quote:
Originally Posted by compbug View Post
well, how could I do that?
could you please explain?

I think it is better way to have an executable for all C codes.... atleast for the trial codes we run to understand the concepts!!

Thanks!
Most compilers let you do something like:
gcc myprogram.c -o myprogram

And anyway there is a mv command that can rename a file. So you could do:
gcc myprogram.c
mv a.out myprogram

But bear in mind that as porter mentioned, a file like xyz.c may not be a program. It could just be a function.
  #6 (permalink)  
Old 09-30-2007
compbug compbug is offline
Registered User
  
 

Join Date: Mar 2006
Posts: 26
got it!

Thanks,

I understood what to be done!!
  #7 (permalink)  
Old 09-30-2007
compbug compbug is offline
Registered User
  
 

Join Date: Mar 2006
Posts: 26
@porter

sorry, I was not specific in asking the question... my question was to renaming the executable to the C code name which can be done by "mv" ....

so , you missed a point about this..


Thanks Man!
Sponsored Links
Closed Thread

Bookmarks

Tags
linux

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 07:41 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0