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:
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:
In this case,
CXXis the path to the C++ compiler, which is defined for you. You can change it by adding the following line to your makefile:If you are trying to avoid echoing back the command make is running, use
@instead of$.