C linux中的Makefile错误 [英] Makefile error in C linux

查看:102
本文介绍了C linux中的Makefile错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在linux中制作我的makefile时出错.这是我的代码:

I have an error while making my makefile in linux. Here's my code:

CC = gcc
CFLAGS = -Wall -m32 -g -fno-stack-protector -z execstack -O0
SHELL_SOURCES = Shell.c

SHELL = Shell

.PHONY: all target1 clean

all: target1 

target1: $(SHELL)

$(SHELL): $(SHELL_SOURCES)
    $(CC) $(CFLAGS) $^ -o $@

clean:
rm -rf $(SHELL)

我得到的错误是:

gcc -Wall -m32 -g -fno-stack-protector -z execstack -O0 Shell.c -o Shell
make: Shell: Command not found
Makefile:16: recipe for target 'Shell' failed
make: *** [Shell] Error 127

推荐答案

您不能在Makefile中将SHELL用作变量,它用于了解什么shell(/bin/sh,/bin/bash,等)将在您的Makefile中使用.

You can't use SHELL as a variable in a Makefile, it is used to know what shell (/bin/sh, /bin/bash, etc) will be used in your Makefile.

CC = gcc
CFLAGS = -Wall -m32 -g -fno-stack-protector -z execstack -O0
EXE_SOURCES = Shell.c

EXE = Shell


.PHONY: all target1 clean

all: target1 

target1: $(EXE)

$(EXE): $(EXE_SOURCES)
    $(CC) $(CFLAGS) $^ -o $@

clean:
    rm -rf $(EXE)

这篇关于C linux中的Makefile错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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