By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
429,101 Members | 1,335 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 429,101 IT Pros & Developers. It's quick & easy.

how to create makefiles in cpp

P: 6
we have been working with a project and we need to create the executables
could u please help us in this aspect

we tried make files this way

vi lab.make

lab.out:prog1.o
g++ -o lab.out prog1.o
prog1.o:prog1.cpp stdio.h
g++ -c prog1.cpp

we executed with
make -f lab.make

its displaying error as fatal error at end of line
thanks in advance
Aug 10 '07 #1
Share this Question
Share on Google+
4 Replies


Expert 10K+
P: 11,448
we have been working with a project and we need to create the executables
could u please help us in this aspect

we tried make files this way

vi lab.make

lab.out:prog1.o
g++ -o lab.out prog1.o
prog1.o:prog1.cpp stdio.h
g++ -c prog1.cpp

we executed with
make -f lab.make

its displaying error as fatal error at end of line
thanks in advance
There should be a tab (or at least a space) as the leading character of the
command execution line; like this:

Expand|Select|Wrap|Line Numbers
  1. lab.out:prog1.o
  2.         g++ -o lab.out prog1.o
  3. prog1.o:prog1.cpp stdio.h
  4.         g++ -c prog1.cpp
  5.  
kind regards,

Jos
Aug 10 '07 #2

P: 93
we have been working with a project and we need to create the executables
could u please help us in this aspect

we tried make files this way

vi lab.make

lab.out:prog1.o
g++ -o lab.out prog1.o
prog1.o:prog1.cpp stdio.h
g++ -c prog1.cpp

we executed with
make -f lab.make

its displaying error as fatal error at end of line
thanks in advance
Did you get error free execution ?

Regards,
Girish.
Aug 10 '07 #3

weaknessforcats
Expert Mod 5K+
P: 9,197
(or at least a space)
Check the O'Reilly book on make. I think this needs to be a tab.
Aug 10 '07 #4

Expert 10K+
P: 11,448
Check the O'Reilly book on make. I think this needs to be a tab.
Yes, old makes need a tab; GNU make for example is happy with one or more
spaces too (hurray for user friendliness! ;-)

kind regards,

Jos
Aug 10 '07 #5

Post your reply

Sign in to post your reply or Sign up for a free account.