У меня есть MinGW, установленный на моей машине с Windows 8.1, и я использую его для разработки кода на C++, который можно портировать в системы Unix/Linux, вместо того, чтобы иметь возможность двойной загрузки Ubuntu или аналогичного.MinGW make on Windows
У меня есть общий make-файл, который должен работать для создания проекта, но по какой-то причине команда find
в Windows не может найти исходные файлы для проекта. Я получаю эту ошибку:
File not found - *.cpp
Makefile:32: *** mixed implicit and normal rules. Stop.
Вот Makefile, я использую (я приспособил его из this блога, наряду с базовой структурой проекта из блога:
CC := g++ # This is the main compiler
# CC := clang --analyze # and comment out the linker last line for sanity
SRCDIR := src # Directory for source code
BUILDDIR := build # Directory containing all object files, which are removed on "make clean"
TARGET := bin/runner # bin/runner contains the main executable for project
# bin/ contains all other executables in the project (such as tests)
SRCEXT := cpp # File extension of source code
# Look for all the source files in SRCDIR with the file extension specified above
SOURCES := $(shell find $(SRCDIR) -type f -name *.$(SRCEXT))
# Name all object files the same root name as the source files from which they came, but add a .o extension to the end
OBJECTS := $(patsubst $(SRCDIR)/%,$(BUILDDIR)/%,$(SOURCES:.$(SRCEXT)=.o))
# The -g flag specifies that debugging information should be produced in the native format of the OS
CFLAGS := -g # -Wall
# Various flags for libraries that might need to be linked
LIB := -pthread -lmongoclient -L lib -lboost_thread-mt -lboost_filesystem-mt -lboost_system-mt
# Ensures that all header files (in the include/ folder) are accessible for build
INC := -I include
# Show the components that are currently being compiled/linked
# Also, this is the main procedure for make: The TARGET is built from the objects, and
# object files are built from source
$(TARGET): $(OBJECTS)
@echo " Linking..."
@echo " $(CC) $^ -o $(TARGET) $(LIB)"; $(CC) $^ -o $(TARGET) $(LIB)
$(BUILDDIR)/%.o: $(SRCDIR)/%.$(SRCEXT)
@mkdir -p $(BUILDDIR)
@echo " $(CC) $(CFLAGS) $(INC) -c -o [email protected] $<"; $(CC) $(CFLAGS) $(INC) -c -o [email protected] $<
# Directives for "make clean" which cleans all object files out of the build/ folder
clean:
@echo " Cleaning...";
@echo " $(RM) -r $(BUILDDIR) $(TARGET)"; $(RM) -r $(BUILDDIR) $(TARGET)
# Tests
# tester:
# $(CC) $(CFLAGS) test/tester.cpp $(INC) $(LIB) -o bin/tester
# Spikes
# ticket:
# $(CC) $(CFLAGS) spikes/ticket.cpp $(INC) $(LIB) -o bin/ticket
# Destroys everything in the build/ and bin/runner/ folders. Does not clean test executables.
.PHONY: clean
Если открыть расширенную консоль в корневой каталог моего проекта и запустить find src/ -name '*.cpp'
, я получаю ту же ошибку, что и выше. Запуск команды dir
Windows из корня также не находит файлы cpp. Однако при запуске из каталога src
dir
может найти все мои исходные файлы, а find
cann ВЗ. Для этого есть причина?