[英]Make error: The system cannot find the path specified
I'm getting a Make error when I run the mingw32-make command:运行 mingw32-make 命令时出现 Make 错误:
PS D:\> mingw32-make
cd src; mingw32-make
The system cannot find the path specified.
mingw32-make: *** [Makefile:4: all] Error 1
But when I list the actual command listed in the Makefile ie cd src; mingw32-make
但是当我列出 Makefile 中列出的实际命令时,即
cd src; mingw32-make
cd src; mingw32-make
, the build is finished successfully. cd src; mingw32-make
,构建成功完成。
PS D:\> cd src; mingw32-make
g++ -std=c++17 -Wall -Wextra -Wpedantic -Wformat -Wchkp -I../include -c account.cpp
g++ -std=c++17 -Wall -Wextra -Wpedantic -Wformat -Wchkp -I../include -c customer.cpp
g++ -std=c++17 -Wall -Wextra -Wpedantic -Wformat -Wchkp -I../include -c display.cpp
g++ -std=c++17 -Wall -Wextra -Wpedantic -Wformat -Wchkp -I../include -c main.cpp
g++ -std=c++17 -Wall -Wextra -Wpedantic -Wformat -Wchkp -I../include -c passbook.cpp
g++ -std=c++17 -Wall -Wextra -Wpedantic -Wformat -Wchkp -I../include -c security.cpp
g++ -std=c++17 -Wall -Wextra -Wpedantic -Wformat -Wchkp -I../include -c staff.cpp
g++ -o Bank account.o customer.o display.o main.o passbook.o security.o staff.o
However this issue is not present when I build using Make on Ubuntu.但是,当我在 Ubuntu 上使用 Make 构建时,不存在此问题。
This is the Makefile in my root directory:这是我根目录中的 Makefile:
DIR = src
all:
cd $(DIR); mingw32-make
clean:
cd $(DIR); mingw32-make clean
This is the Makefile in my src subdirectory:这是我的 src 子目录中的 Makefile:
# Compiler options
# -std=c++17 enables ISO C++ 17 standard
CC = g++
CCFLAGS = -std=c++17 -Wall -Wextra -Wpedantic -
Wformat -Wchkp
i = ../include
# LOCFLAGS used to set tell the compiler where to find a
# header that is not in the same directory as the source
file itself
# LOCFLAGS will be set in directory level makefiles as
needed
LOCFLAGS = -I../include
# The list of object files that can be made in this
subdirectory
# is assigned to the make macro named $OBJECTS
OBJECTS = account.o customer.o display.o main.o
passbook.o \
security.o staff.o
# This rule says that the target named "all" depends on
those
# files. Executing "make all" in this subdirectory will cause
# make to build the object files (.o) listed in the macro
$OBJECTS
# and create an executable named "Bank" by linking them
all: $(OBJECTS)
$(CC) -o Bank $(OBJECTS)
# rule that says how to make a .o object file from a .cpp
source file
# for a given source file in a given directory you could
compile it
# into an object file by executing "make filename.o"
# $< and $@ are macros defined by make
# $< refers to the file being processed (i.e., compiled or
linked )
# $@ refers to the generated file
%.o: %.cpp
$(CC) $(CCFLAGS) $(LOCFLAGS) -c $<
# target to clean up the object files, core files and
executables
# executing "make clean" in this subdirectory will remove
all
# files named core, "Bank" or any file ending in .o or
.stackdump
clean:
del $(OBJECTS) core *.stackdump Bank
On Windows you're running in a command.com shell, not a POSIX shell.在 Windows 上,您正在运行命令。com shell,而不是 POSIX Z2591C98B70119FE6E9429。 In command.com, the syntax
cd src; mingw32-make
在 command.com 中,语法
cd src; mingw32-make
cd src; mingw32-make
is not legal. cd src; mingw32-make
是不合法的。 For example if I open a command.com terminal on a Windows system I see:例如,如果我在 Windows 系统上打开一个 command.com 终端,我会看到:
C:\Users\build> cd src; echo hi
The system cannot find the path specified.
In Windows command.com the command separator is a single &
not a semicolon.在
&
command.com 命令分隔符是单个而不是分号。
If you want to change directories portably you can use the -C
option to GNU make.如果您想以可移植的方式更改目录,您可以使用 GNU make 的
-C
选项。 Also you should always use the $(MAKE)
variable, not write out the make command by hand:此外,您应该始终使用
$(MAKE)
变量,而不是手动写出 make 命令:
all:
$(MAKE) -C $(DIR)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.