&“找不到文件"生成文件错误 [英] "Can not find file" makefile error

查看:89
本文介绍了&“找不到文件"生成文件错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用make编译C ++程序.我希望它从src文件夹中读取源文件.将目标文件放在build文件夹中,然后将exe放在bin文件夹中.

I am trying to compile a C++ program using make. I want it to read the source files from the src folder. Place the object files in the build folder, and put the exe in the bin folder.

我收到以下错误

/bin/wavfiletool.exe -g -O2 process_begin:CreateProcess(NULL,/bin/wavfiletool.exe -g -O2, ...) 失败.make(e = 2):系统找不到指定的文件.

/bin/wavfiletool.exe -g -O2 process_begin: CreateProcess(NULL, /bin/wavfiletool.exe -g -O2, ...) failed. make (e=2): The system cannot find the file specified.

更新:问题是我将g ++放入我的编译器var中,而不是&(CC)... woops.

UPDATE: The problem was I put g++ in for my compiler var instead of &(CC)...woops.

但现在它说 g++:致命错误:没有输入文件我正在使用设置环境变量的批处理文件运行make.

But now it says g++: fatal error: no input files I am running make using a batch file that sets the environment variables.

SET PATH=C:\Make\GnuWin32\bin;C:\MinGW\bin
make %1

我的makefile如下.

My makefile is as follows.

CC := g++
CFLAGS := -g -O2
BIN_DIR := /bin
BUILD_DIR := /build
SRC_DIR := /src
TARGET := wavfiletool.exe
SOURCES  := $(wildcard $(SRC_DIR)/*.c)
OBJECTS  := $(SOURCES:$(SRCDIR)/%.cpp=$(OBJDIR)/%.o)

$(BIN_DIR)/$(TARGET): $(OBJECTS)
    $(G++) $@ $(CFLAGS) $(OBJECTS)

$(OBJECTS): $(OBJDIR)/%.o : $(SRCDIR)/%.c
    @$(CC) $(CFLAGS) -c $< -o $@

推荐答案

您尚未在任何地方设置 $(G ++)变量,因此 $(BIN_DIR)/$(TARGET)目标正在尝试运行 $ @ 而不是编译器.

You haven't set the $(G++) variable anywhere so the recipe line for the $(BIN_DIR)/$(TARGET) target is trying to run $@ instead of the compiler.

在该编译行上还缺少 -o ,因此将 $(G ++)正确设置为 g ++ ,您最终会运行:

Also you are missing -o on that compilation line so were $(G++) set to g++ correctly you would end up running:

g++ /bin/wavfiletool.exe -g -O2 $(OBJECTS)

可能不是您想要的.

是说您可能不想将直接写入/bin 中.您是在本地目录中的 bin 目录中表示 ./bin 吗?

That being said you probably don't want to be writing directly into /bin either. Did you mean ./bin for a bin directory in the local directory?

这篇关于&amp;“找不到文件"生成文件错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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