make:c:找不到命令 [英] make: c: command not found

查看:276
本文介绍了make:c:找不到命令的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图运行我的make文件,但我得到以下两个错误:

I am attempting to run my make file however i am getting the following two errors:

make:c:command not found

make: c: command not found

make:o:未找到命令

make: o: command not found

这里面cygwin。我有g ++并安装它,但是当我运行make文件我收到这些错误。

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.

任何想法?

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


推荐答案

您需要从 $ g ++ 行中删除 $ 。它试图扩展一些不存在的变量,并从你的命令吞下 $ g ++ -

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.

使用变量的语法是:

$(CXX) -c main.cpp

在这种情况下, CXX 是C ++编译器的路径,这是为您定义的。您可以通过在makefile中添加以下行来更改它:

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++

如果您试图避免回显命令make正在运行,请使用 @ $

If you are trying to avoid echoing back the command make is running, use @ instead of $.

这篇关于make:c:找不到命令的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆