“无法找到文件” makefile错误 [英] "Can not find file" makefile error

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

问题描述

我想使用make编译一个C ++程序。我想它从src文件夹中读取源文件。



我收到以下错误


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




更新:问题是我把g ++



但是现在它说的是g ++:fatal error:没有输入文件
我是我的编译器var而不是&使用设置环境变量的批处理文件运行make。

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

我的makefile如下。

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

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

$(OBJECTS):$(OBJDIR)/% $(CC)$(CFLAGS)-c $& -o $ @


解决方案

code> $(G ++)变量,因此 $(BIN_DIR)/ $(TARGET)目标的配方行试图 $

$ code>在那个编译行上,因此 $(G ++)设置为 g ++

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



>说你可能不想直接写 / bin 。您是指 ./ bin 为本地目录中的 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.

I get the following error

/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.

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

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

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 $@

解决方案

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.

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)

which likely isn't what you want.

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?

这篇关于“无法找到文件” makefile错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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