Linux make: c: 命令未找到
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/5256663/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
make: c: command not found
提问by Matt
I am attempting to run my make file however i am getting the following two errors:
我正在尝试运行我的 make 文件,但是我收到以下两个错误:
make: c: command not found
make: c: 命令未找到
and
和
make: o: command not found
make: o: 找不到命令
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.
我正在尝试在 cygwin 中执行此操作。我在上面安装了 g++ 和 make,但是当我运行 make 文件时,我收到了这些错误。
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
采纳答案by Daniel Gallagher
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.
您需要$
从$g++
行中删除。它试图扩展一些不存在的变量,并$g++ -
从你的命令中吞下“ ”。
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
是为您定义的 C++ 编译器的路径。您可以通过在 makefile 中添加以下行来更改它:
CXX = g++
If you are trying to avoid echoing back the command make is running, use @
instead of $
.
如果您试图避免回显正在运行的命令,请使用@
代替$
。
回答by Dirk
$g++ is not defined in that makefile, so the command becomes
$g++ 未在该 makefile 中定义,因此命令变为
-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.
要么从 $g++ 中删除 $ 并使用 g++,要么在你的 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