I am attempting to run my make file however i am getting the following two errors:
make: c: command not found
and
make: o: command not found
I am attempting to do this inside of cygwin. I have g++ and make installed on it, however when I run the make file I receive these errors.
Any ideas?
The makefile:
all: MergeSort clean
MergeSort: main.o MergeSort.o
$g++ -o MergeSort main.o MergeSort.o
main.o: main.cpp MergeSort.h
$g++ -c main.cpp
MergeSort.o: MergeSort.cpp MergeSort.h
$g++ -c MergeSort.cpp
clean:
rm -rf *o
cleanall:开发者_StackOverflow社区
rm -rf *o *exe
You need to remove the $
from the $g++
lines. It's trying to expand some variable that doesn't exist, and is swallowing up the "$g++ -
" from your commands.
The syntax for using a variable is:
$(CXX) -c main.cpp
In this case, CXX
is the path to the C++ compiler, which is defined for you. You can change it by adding the following line to your makefile:
CXX = g++
If you are trying to avoid echoing back the command make is running, use @
instead of $
.
$g++ is not defined in that makefile, so the command becomes
-o MergeSort main.o MergeSort.o
and
-c main.cpp
Either drop the $ from $g++ and use g++, or define the variable in your makefile.
CXX = g++
all: MergeSort clean
MergeSort: main.o MergeSort.o
$CXX -o MergeSort main.o MergeSort.o
main.o: main.cpp MergeSort.h
$CXX -c main.cpp
MergeSort.o: MergeSort.cpp MergeSort.h
$CXX -c MergeSort.cpp
clean:
rm -rf *o
cleanall:
rm -rf *o *exe
精彩评论