Windows 发生错误:系统找不到指定的路径
运行mingw32 Make命令时,我遇到一个Make错误:Windows 发生错误:系统找不到指定的路径,windows,makefile,mingw,Windows,Makefile,Mingw,运行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 但是当我列出Makefile中列出的实际命令时,即cd src;mingw32 make,生成已成功完成 PS D:\> cd src; mingw32-make g
PS D:\> mingw32-make
cd src; mingw32-make
The system cannot find the path specified.
mingw32-make: *** [Makefile:4: all] Error 1
但是当我列出Makefile中列出的实际命令时,即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
然而,当我在Ubuntu上使用Make构建时,这个问题并不存在
这是我的根目录中的Makefile:
DIR = src
all:
cd $(DIR); mingw32-make
clean:
cd $(DIR); mingw32-make clean
# 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
这是我的src子目录中的Makefile:
DIR = src
all:
cd $(DIR); mingw32-make
clean:
cd $(DIR); mingw32-make clean
# 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
#编译器选项
C++ -STD=C++ 17实现ISO C++ 17标准
CC=g++
CCFLAGS=-std=c++17-Wall-Wextra-Wpedantic-
Wformat-Wchkp
i=../include
#用于设置的LOCFLAGS告诉编译器在何处查找
#与源不在同一目录中的头
文件本身
#LOCFLAGS将在目录级makefiles中设置为
需要
LOCFLAGS=-I../include
#可在此文件中创建的对象文件列表
子目录
#指定给名为$OBJECTS的make宏
对象=account.o customer.o display.o main.o
存折\
保安
#此规则表示名为“all”的目标依赖于
那些
#档案。在此子目录中执行“全部生成”将导致
#生成宏中列出的对象文件(.o)
$OBJECTS
#并通过链接它们来创建一个名为“Bank”的可执行文件
全部:$(对象)
$(CC)-o银行$(对象)
#说明如何从.cpp生成.o对象文件的规则
源文件
#对于给定目录中的给定源文件,您可以
编译它
#通过执行“makefilename.o”将文件转换为对象文件
#$<和$@是make定义的宏
#$<指正在处理的文件(即编译或
链接)
#$@引用生成的文件
%.o:%.cpp
$(CC)$(CCFLAGS)$(LOCFLAGS)-c$<
#目标清理对象文件、核心文件和
可执行文件
#在此子目录中执行“makeclean”将删除
全部的
#文件名为core,“Bank”或任何以.o结尾的文件,或
.堆垛机
清洁:
del$(对象)核心*.stackdump银行
在Windows上,您运行的是command.com shell,而不是POSIX shell。在command.com中,语法为cd src;mingw32 make
不合法。例如,如果我在Windows系统上打开command.com终端,我会看到:
C:\Users\build> cd src; echo hi
The system cannot find the path specified.
在Windows command.com中,命令分隔符是单个&
而不是分号
如果您想以便携方式更改目录,可以使用GNU make的-C
选项。此外,应始终使用$(MAKE)
变量,而不是手动写出MAKE命令:
all:
$(MAKE) -C $(DIR)