Command line argument make.
Nov 13, 2013 at 2:45pm UTC
I have to pass an argument when I run make postfix. I am confused on how to do this. And I really need any kind of help. Thank you.
MAKE COMMAND : make postfix
File I want to give : data3-1.txt
Makefile for the make postfix is:
1 2 3 4 5
postfix.o: postfix.cpp ${STRING_DIR}string.hpp stack.hpp
${CPP} ${CPP_FLAGS} ${INCLUDE_OPT} -c postfix.cpp
postfix: postfix.o string.o
${CPP} ${CPP_FLAGS} postfix.o string.o -o postfix
I have tried looking up the answer and the best I got is to change the Makefile,
1 2
postfix: postfix.o string.o
${CPP} ${CPP_FLAGS} $(argument) postfix.o string.o -o postfi
and then type on the command line something like.
$ : make postfix argument="data3-1.txt"
But I get some errors about .txt not being a regonized format. Do I have it in the wrong place or am I completely wrong?
Thank you.
Nov 13, 2013 at 3:46pm UTC
$ make postfix argument="data3-1.txt"
¿what do you expect to happen when you write that?
With that rule you'll have
$ g++ data3-1.txt postfix.o string.o -o postfi
¿does that make sense to you?
¿what is a *.txt doing in a build command?
Nov 14, 2013 at 7:34pm UTC
Thats why I was wondering if that was right. Which I did not think it was. I am just trying to figure out how to give a command line argument with a make command.
Nov 15, 2013 at 1:05am UTC
I'll ask again, ¿what do you want to happen?
Nov 17, 2013 at 9:20pm UTC
I figured it out. It was
$: make postfix
$: ./postfix "data3-1.txt"
Thanks for your help though.
Topic archived. No new replies allowed.