LinuxQuestions.org
Register a domain and help support LQ
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 01-25-2005, 06:26 PM   #1
elite_duke
LQ Newbie
 
Registered: Feb 2004
Posts: 9

Rep: Reputation: 0
Makefile & Executable


Ok I'm really newb to this,

I wrote a program, say robot.cc, and i want to write a makefile for it, so that when i type

robot [filename]

where filename is an input file, it will compile the robot.cc and take in the input file with name "filename", and if filename is not present, then just run

./a.out instead of ./a.out filename

i know it looks something like

robot $X:
g++ robot.cc
./a.out $X

but doesnt seem to work

Thanks in advance.
 
Old 01-25-2005, 06:52 PM   #2
Tinkster
Moderator
 
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 23,005
Blog Entries: 11

Rep: Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903
Why do you want to force a recompile of the robot.cc
on every run in the first place?


Cheers,
Tink
 
Old 01-25-2005, 09:02 PM   #3
elite_duke
LQ Newbie
 
Registered: Feb 2004
Posts: 9

Original Poster
Rep: Reputation: 0
not everytime, just compile once, the next time robot is called, assume no changes in *.cc, it will be robot instead of ./a.out
 
Old 01-26-2005, 02:48 AM   #4
jlliagre
Moderator
 
Registered: Feb 2004
Location: Outside Paris
Distribution: Solaris10, Solaris 11, Mint, OL
Posts: 9,523

Rep: Reputation: 365Reputation: 365Reputation: 365Reputation: 365
When you type robot, how do you want the Makefile to be used ?
Usually a Makefile is processed by the make command.

Or is it "make robot" what you meant ?
 
Old 01-26-2005, 11:05 AM   #5
Padma
Member
 
Registered: Aug 2003
Location: Omaha, NE, USA
Distribution: PCLinuxOS 2007
Posts: 808

Rep: Reputation: 30
I guess we more experienced folks are just a bit confused about what you are trying to do.

A makefile is used by the "make" command to compile source code into an executable program. (Yeah, it *can* do more, but that's its basic intent. ) So you type

$ make robot

and the instructions in the makefile will take robot.cc and produce an executable program, presumably named "robot". Then, you run "robot" by typing

$ robot [filename]

and "robot" will do whatever it's supposed to do with "filename".

If this isn't what you are trying to do, we need a little more clarification.
 
  


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
[bsdmake/pmake] Makefile Fun & Games darklogik_org Programming 2 02-13-2005 02:34 PM
Makefile & Executable elite_duke Programming 5 01-25-2005 09:04 PM
How can I use "Makefile.in" for building an executable program? wuzhong Linux - Networking 1 10-06-2004 11:00 AM
Non executable stack with Linux -- && 64bit CPU needed? lelolas Linux - Security 5 07-25-2004 10:25 PM
Sendmail & How to reject mail with executable attachments WorldBuilder Linux - Networking 3 02-04-2004 04:27 PM


All times are GMT -5. The time now is 12:20 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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration