Сделать ошибку: система не может найти указанный путь - PullRequest
0 голосов
/ 20 апреля 2020

Я получаю ошибку Make при запуске команды mingw32-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++ -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

Однако эта проблема отсутствует при сборке с использованием Make на Ubuntu.

Это Makefile в моем каталоге root:

DIR = src

all:
    cd $(DIR); mingw32-make

clean:
    cd $(DIR); mingw32-make clean

This это Makefile в моем подкаталоге sr c:

# 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

1 Ответ

1 голос
/ 20 апреля 2020

На Windows вы работаете в оболочке command.com, а не в оболочке POSIX. В command.com синтаксис cd src; mingw32-make недопустим. Например, если я открываю терминал command.com в системе Windows, я вижу:

C:\Users\build> cd src; echo hi
The system cannot find the path specified.

В Windows command.com разделитель команд - это один &, а не точка с запятой.

Если вы хотите переносить каталоги поочередно, вы можете использовать опцию -C в GNU make. Также вы всегда должны использовать переменную $(MAKE), а не записывать команду make вручную:

all:
        $(MAKE) -C $(DIR)
...