LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
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 02-09-2011, 06:44 AM   #1
Ajit Gunge
Member
 
Registered: Jan 2008
Location: Pune
Distribution: RHEL,fedora
Posts: 253
Blog Entries: 1

Rep: Reputation: 21
Help with programming!!(make files)


Hi,
I am new to linux and right now I am just following a tutorial.
I have these two files EchoClient.c and EchoServer.c and a Makefile.txt for them.Now I want to know what command do I have to execute from the shell so as to create the output of the makefile.Please let me know.

-Ajit
 
Old 02-09-2011, 06:53 AM   #2
onebuck
Moderator
 
Registered: Jan 2005
Location: Central Florida 20 minutes from Disney World
Distribution: SlackwareŽ
Posts: 13,927
Blog Entries: 45

Rep: Reputation: 3159Reputation: 3159Reputation: 3159Reputation: 3159Reputation: 3159Reputation: 3159Reputation: 3159Reputation: 3159Reputation: 3159Reputation: 3159Reputation: 3159
Moved: This thread is more suitable in <Programming> and has been moved accordingly to help your thread/question get the exposure it deserves.
 
Old 02-09-2011, 06:57 AM   #3
tronayne
Senior Member
 
Registered: Oct 2003
Location: Northeastern Michigan, where Carhartt is a Designer Label
Distribution: Slackware 32- & 64-bit Stable
Posts: 3,541

Rep: Reputation: 1065Reputation: 1065Reputation: 1065Reputation: 1065Reputation: 1065Reputation: 1065Reputation: 1065Reputation: 1065
First off, a Makefile is named "Makefile," not "Makefile.anything;" that'll cause you problems.

So,
Code:
prompt: mv Makefile.txt Makefile
prompt: make
You can, actually, name a Makefile anything you want to (although that will get confusing after a while) and execute the make utility
Code:
make -f WhatEverNameYouGaveIt
and that will work but you probably see where this is going, eh? The make utility "looks for" a file named "Makefile" by default, probably a good idea to simply follow that.

Hope this helps some.
 
Old 02-09-2011, 07:07 AM   #4
Ajit Gunge
Member
 
Registered: Jan 2008
Location: Pune
Distribution: RHEL,fedora
Posts: 253

Original Poster
Blog Entries: 1

Rep: Reputation: 21
Quote:
Originally Posted by tronayne View Post
First off, a Makefile is named "Makefile," not "Makefile.anything;" that'll cause you problems.

So,
Code:
prompt: mv Makefile.txt Makefile
prompt: make
You can, actually, name a Makefile anything you want to (although that will get confusing after a while) and execute the make utility
Code:
make -f WhatEverNameYouGaveIt
and that will work but you probably see where this is going, eh? The make utility "looks for" a file named "Makefile" by default, probably a good idea to simply follow that.

Hope this helps some.
Hi Tronayne,
I am getting the following error when I executed the command you specified....

Quote:
make: *** No rule to make target `EchoServer.c', needed by `EchoServer'. Stop.

Ajit
 
Old 02-09-2011, 10:12 AM   #5
tronayne
Senior Member
 
Registered: Oct 2003
Location: Northeastern Michigan, where Carhartt is a Designer Label
Distribution: Slackware 32- & 64-bit Stable
Posts: 3,541

Rep: Reputation: 1065Reputation: 1065Reputation: 1065Reputation: 1065Reputation: 1065Reputation: 1065Reputation: 1065Reputation: 1065
Your C source files, EchoClient.c and EchoServer.c, what are they? That is, are they both main program source files? Is one a main and the other a function?

If they are both main files, a Makefile would look something like this:
Code:
MAKEFILE =      Makefile

MAINS   =       EchoClient EchoServer

OBJECTS =       EchoClient.o EchoServer.o

SOURCES =       EchoClient.c EchoServer.c

ALL:            $(MAINS)

EchoClient:             EchoClient.o
        $(CC) $(CFLAGS) -o EchoClient EchoClient.o

EchoServer:             EchoServer.o
        $(CC) $(CFLAGS) -o EchoServer EchoServer.o $(LDFLAGS)

EchoClient.o:

EchoServer.o:
It would probably be a good idea to read http://en.wikipedia.org/wiki/Make_%28software%29 to gain an understanding of what make and Makefiles are all about.

Hope this helps some.
 
  


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
Shell programming: Question about source files and read data from the files ccwq Programming 3 08-05-2007 12:13 AM
Please make me better in programming cigarstub Programming 43 04-09-2007 09:15 AM
gnu make recompiles the source files fully even though the files are not modified yasothamani Linux - Software 4 02-07-2007 06:36 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 08:01 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
Open Source Consulting | Domain Registration