GIDForums  

Go Back   GIDForums > Computer Programming Forums > C++ Forum
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
 
Thread Tools Search this Thread Rate Thread
  #1  
Old 14-Mar-2005, 09:45
ap6118 ap6118 is offline
Junior Member
 
Join Date: Feb 2005
Posts: 62
ap6118 is on a distinguished road

makefile


does anyone knows how to create a makefile on telnet?no mattr what i put in there it just would not compile.
  #2  
Old 15-Mar-2005, 15:08
davekw7x davekw7x is offline
Outstanding Member
 
Join Date: Feb 2004
Location: Left Coast, USA
Posts: 5,496
davekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to behold
Quote:
Originally Posted by ap6118
does anyone knows how to create a makefile on telnet?no mattr what i put in there it just would not compile.
Show us what you are trying to do (and what you tried). Make files can be quite elaborate for big, complex projects, or can be very simple for small projects.

Also tell us what make program you are using (Borland, GNU, Microsoft nmake, or what?) Some have different "features" than others (and different defaults, depending on your operating system setup).

Regards,

Dave

(Oh, no!!! I just noticed this is my post number 666 --- the Mark of the Beast! I don't know what's going to happen next...)
  #3  
Old 20-Mar-2005, 10:26
ap6118 ap6118 is offline
Junior Member
 
Join Date: Feb 2005
Posts: 62
ap6118 is on a distinguished road

nothing big


nothing complex just an easy makefile for unix,i use putty and telnet,what i have tried so far is this format


run: cats.o cats.o
g++ -o run cats.o cats.o

cats.o: cats.cpp cats.h
g++ -c cats.cpp
cats.o: cats.cpp
g++ -c cats.cpp


but it is not working at all.keeps telling me there ia a mistake at line 4
  #4  
Old 20-Mar-2005, 11:49
davekw7x davekw7x is offline
Outstanding Member
 
Join Date: Feb 2004
Location: Left Coast, USA
Posts: 5,496
davekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to behold
Quote:
Originally Posted by ap6118


but it is not working at all.keeps telling me there ia a mistake at line 4

It would help if you posted the exact message (copy and paste into your post). I don't know which line is line 4.

Here are a few questions about your makefile:

Why do you have two different rules for making cats.o?
Why do you link cats.o twice?


Now, look at this:

CPP / C++ / C Code:
run:  cats.o
        g++ -o run cats.o

cats.o: cats.cpp cats.h
        g++ -c cats.cpp

This looks like it should probably work, ***HOWEVER*** with this as the makefile, GNU make gives the following error:

Quote:
makefile:2: *** missing separator (did you mean TAB instead of 8 spaces?). Stop.

The make program requires tabs in the action line (eight spaces will not work with GNU make).

So, in the makefile, replace the spaces in front of the "g++" command lines with a tab.

With this as my makefile, when I run make, I get:
Quote:
g++ -c cats.cpp
g++ -o run cats.o

**edit** As I review your previous posts with "cats", I guess that you have two cpp files in your project.

So a simple makefile could look something like this:

CPP / C++ / C Code:
run:  cats.o catsm.o
	g++ -o run cats.o catsm.o

cats.o: cats.cpp cats.h
	g++ -c cats.cpp

catsm.o: catsm.cpp cats.h
	g++ -c catsm.cpp


Remember: real tabs in front of the "g++" each time.


Regards,

Dave
Last edited by davekw7x : 20-Mar-2005 at 12:56. Reason: Added information about two source files
  #5  
Old 21-Mar-2005, 09:22
bravetanveer bravetanveer is offline
New Member
 
Join Date: Jan 2005
Posts: 11
bravetanveer is on a distinguished road
make file is a good utility to use, but at the same time u have to follow certain rules of makefile

tabs are important before a rule or else it will give error.

Suppose tomorrow u want to compile the same application on gcc or armcc then u can use the same makefile by just defining ur own variable

example: makefile.mk
********
CC= g++

main.o:main.c main.h
$(CC) main.c main.h

*********

Then give
make -f makefile.mk

Simple utility to compile only those files that get modified.
  #6  
Old 21-Mar-2005, 10:29
ap6118 ap6118 is offline
Junior Member
 
Join Date: Feb 2005
Posts: 62
ap6118 is on a distinguished road

a whole different thing!


thank you guys.i tried using tabs instead of spaces,and it stopped giving me,the eroor at line four thing.Unfortunatly,it is giving the following message :
"fatal error : don't know how to make targer "cats.co" ".i followed the template,provided by Dave in the previous reply.
what am i missing?
the template provided by my text book is no different,by generating the same problem.could it be the compiler itself?

ps: i have tried it on putty,and telnet.
  #7  
Old 21-Mar-2005, 10:34
ap6118 ap6118 is offline
Junior Member
 
Join Date: Feb 2005
Posts: 62
ap6118 is on a distinguished road
Talking

oopsy


nevermind,i fixed it.lol.it was my mistake actually.a little typo.
thank you guys for your help.
  #8  
Old 21-Mar-2005, 10:48
ap6118 ap6118 is offline
Junior Member
 
Join Date: Feb 2005
Posts: 62
ap6118 is on a distinguished road
Question

something a bit unusual.


ok.so the program runs fine on microsoft visual c++.i created the makefile,with everyone's help,and typed in the command "make".
and this is what i got as a message.

cats.cpp: in function int main () :
cats.cpp:35: name lookup of 'c' changed for new ANSI 'for' scoping
cats.cpp:22: using absolete binding at 'c'

i looked up the lines 35 and 22 of the cats.cpp file,and found nothing relevant,

line 35 = delete pen[c];
line 22 = for ( int c = 0; c < PEN_SIZE; c++ ) {


why would it work on windows and not on unix?
  #9  
Old 21-Mar-2005, 13:02
davekw7x davekw7x is offline
Outstanding Member
 
Join Date: Feb 2004
Location: Left Coast, USA
Posts: 5,496
davekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to behold
Quote:
Originally Posted by ap6118
cats.cpp: in function int main () :
cats.cpp:35: name lookup of 'c' changed for new ANSI 'for' scoping
cats.cpp:22: using absolete binding at 'c'

i looked up the lines 35 and 22 of the cats.cpp file,and found nothing relevant,

line 35 = delete pen;
line 22 = for ( int c = 0; c < PEN_SIZE; c++ ) {


It's kind of hard to tell without knowing exactly what's between line 22 and line 35, but I'll take a stab:

When the variable c is declared in a for statement, its scope is limited to that for loop.

Some compilers let you use the variable after you leave the loop, but not others enforce the standard.

If that doesn't make sense (or doesn't apply) post the code that shows some context.

The following code compiles without errors with Microsoft VC++, but gives errors with GNU g++ and Borland bcc32:

CPP / C++ / C Code:
#include <iostream>

using std::cout;
using std::endl;

int main()
{
  for (int i = 0; i < 5; i++) {
    cout << "Inside the loop: i = " << i << endl;
  }

  cout << "After the loop: i = " << i << endl;

  return 0;
}

(It is not legal according to the C++ standard.)

Here's the g++ error message:

Quote:
z.cpp: In function `int main()':
z.cpp:12: error: name lookup of `i' changed for new ISO `for' scoping
z.cpp:8: error: using obsolete binding at `i'

Look familiar?

Bottom line: just because Microsoft lets you do something, does not necessarily imply that it's a "Good Thing to Do".

Regards,

Dave
Last edited by davekw7x : 21-Mar-2005 at 13:22. Reason: Added example
 
 

Recent GIDBlogProblems with the Navy (Enlisted) by crystalattice

Thread Tools Search this Thread
Search this Thread:

Advanced Search
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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
GIMcontacts - a gim fltk fluid venture cable_guy_67 FLTK Forum 0 14-Feb-2005 14:18
Multi-File C Project. Layla C Programming Language 1 31-Jan-2005 13:33
.o compile UNIX stuff ... help please! crq C++ Forum 5 28-Jan-2005 07:43

Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The

All times are GMT -6. The time now is 18:55.


vBulletin, Copyright © 2000 - 2010, Jelsoft Enterprises Ltd.