![]() |
|
#1
|
|||
|
|||
makefiledoes anyone knows how to create a makefile on telnet?no mattr what i put in there it just would not compile.
|
|||
|
#2
|
|||
|
|||
|
Quote:
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
|
|||
|
|||
nothing bignothing 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
|
|||
|
|||
|
Quote:
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:
This looks like it should probably work, ***HOWEVER*** with this as the makefile, GNU make gives the following error: Quote:
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:
**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:
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
|
|||
|
|||
|
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
|
|||
|
|||
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
|
|||
|
|||
oopsynevermind,i fixed it.lol.it was my mistake actually.a little typo.
thank you guys for your help. |
|
#8
|
|||
|
|||
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
|
|||
|
|||
|
Quote:
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:
(It is not legal according to the C++ standard.) Here's the g++ error message: Quote:
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 GIDBlog
Problems with the Navy (Enlisted) by crystalattice
| Thread Tools | Search this Thread |
| Rate This Thread | |
|
|
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