Điều này gây nhầm lẫn. Tôi có Makefile của tôi:GNU Tạo kết quả hoàn toàn khác
OBJECTS =
INCLUDE_BUILD_PATH = /Users/wen/Projects/include
# Change compilation settings here
COMPILE = g++
override COMPILE_FLAGS += -O2
# Change linker/compiler specific settings here
LD_FLAGS :=
CC_FLAGS := -c -I$(INCLUDE_BUILD_PATH)/bigint
# Add source extensions here
SRC_EXT = cpp cc
# Add header dependencies here
HEADERS = $(wildcard *.hpp) $(wildcard $(INCLUDE_BUILD_PATH)/*/*.hh)
# Add source files here
CC_FILES = $(wildcard *.cpp) $(wildcard $(INCLUDE_BUILD_PATH)/*/*.cc)
CC_O_BUFFER = $(CC_FILES)
CC_O_BUFFER := $(CC_O_BUFFER:.cpp=.o)
CC_O_BUFFER := $(CC_O_BUFFER:.cc=.o)
OBJECTS = $(CC_O_BUFFER)
# Change .exe name here
EXE_NAME = maketest
# Link object files
$(EXE_NAME): $(OBJECTS)
$(COMPILE) $(COMPILE_FLAGS) $(LD_FLAGS) -o [email protected] $^
# Build source files
define compile_rule
%.o : %.$1
$$(COMPILE) $$(COMPILE_FLAGS) $$(CC_FLAGS) -o [email protected] $$<
endef
$(foreach EXT,$(SRC_EXT),$(eval $(call compile_rule,$(EXT))))
# Clean
clean:
rm -f $(OBJECTS) $(EXE_NAME)
# Debug Build
debug:
@echo "Rerun with COMPILE_FLAGS=-D_DEBUG"
# Print variables
print:
@echo $(CC_FILES)
@echo $(OBJECTS)
@echo $(HEADERS)
nó được biên dịch thành công lúc đầu, nhưng sau đó nó dừng lại không có lý do và đây là kết quả:
Yoshi-Air:maketest wen$ make
c++ -c -o maketest.o maketest.cpp
maketest.cpp:4:10: fatal error: 'BigIntegerLibrary.hh' file not found
#include "BigIntegerLibrary.hh"
^
1 error generated.
vấn đề là, tôi thậm chí còn không nói với nó để sử dụng "C++" trong Makefile nhưng "g ++" để thay thế. Ngoài ra, khi tôi xóa CC_FLAGS
, -c
vẫn ở đó. Nó giống như Make có một tâm trí riêng của nó.
Nếu tôi sử dụng make print
để in ra các biến của tôi nó có vẻ là ổn thôi:
maketest.cpp /Users/wen/Projects/include/bigint/BigInteger.cc /Users/wen/Projects/include/bigint/BigIntegerAlgorithms.cc /Users/wen/Projects/include/bigint/BigIntegerUtils.cc /Users/wen/Projects/include/bigint/BigUnsigned.cc /Users/wen/Projects/include/bigint/BigUnsignedInABase.cc
maketest.o /Users/wen/Projects/include/bigint/BigInteger.o /Users/wen/Projects/include/bigint/BigIntegerAlgorithms.o /Users/wen/Projects/include/bigint/BigIntegerUtils.o /Users/wen/Projects/include/bigint/BigUnsigned.o /Users/wen/Projects/include/bigint/BigUnsignedInABase.o
maketest.hpp /Users/wen/Projects/include/bigint/BigInteger.hh /Users/wen/Projects/include/bigint/BigIntegerAlgorithms.hh /Users/wen/Projects/include/bigint/BigIntegerLibrary.hh /Users/wen/Projects/include/bigint/BigIntegerUtils.hh /Users/wen/Projects/include/bigint/BigUnsigned.hh /Users/wen/Projects/include/bigint/BigUnsignedInABase.hh /Users/wen/Projects/include/bigint/NumberlikeArray.hh
Bất kỳ giúp đỡ hoặc tư vấn sẽ được đánh giá cao. Cảm ơn!
Cập nhật
tôi cập nhật của tôi print
in thực hiện dự kiến biên dịch:
print:
@echo $(CC_FILES)
@echo $(OBJECTS)
@echo $(HEADERS)
@echo "Compiles with:"
@echo $(COMPILE) $(COMPILE_FLAGS) $(LD_FLAGS) $(CC_FLAGS)
Kết quả:
maketest.cpp /Users/wen/Projects/include/bigint/BigInteger.cc /Users/wen/Projects/include/bigint/BigIntegerAlgorithms.cc /Users/wen/Projects/include/bigint/BigIntegerUtils.cc /Users/wen/Projects/include/bigint/BigUnsigned.cc /Users/wen/Projects/include/bigint/BigUnsignedInABase.cc
maketest.o /Users/wen/Projects/include/bigint/BigInteger.o /Users/wen/Projects/include/bigint/BigIntegerAlgorithms.o /Users/wen/Projects/include/bigint/BigIntegerUtils.o /Users/wen/Projects/include/bigint/BigUnsigned.o /Users/wen/Projects/include/bigint/BigUnsignedInABase.o
maketest.hpp /Users/wen/Projects/include/bigint/BigInteger.hh /Users/wen/Projects/include/bigint/BigIntegerAlgorithms.hh /Users/wen/Projects/include/bigint/BigIntegerLibrary.hh /Users/wen/Projects/include/bigint/BigIntegerUtils.hh /Users/wen/Projects/include/bigint/BigUnsigned.hh /Users/wen/Projects/include/bigint/BigUnsignedInABase.hh /Users/wen/Projects/include/bigint/NumberlikeArray.hh
Yoshi-Air:maketest wen$ make print
maketest.cpp /Users/wen/Projects/include/bigint/BigInteger.cc /Users/wen/Projects/include/bigint/BigIntegerAlgorithms.cc /Users/wen/Projects/include/bigint/BigIntegerUtils.cc /Users/wen/Projects/include/bigint/BigUnsigned.cc /Users/wen/Projects/include/bigint/BigUnsignedInABase.cc
maketest.o /Users/wen/Projects/include/bigint/BigInteger.o /Users/wen/Projects/include/bigint/BigIntegerAlgorithms.o /Users/wen/Projects/include/bigint/BigIntegerUtils.o /Users/wen/Projects/include/bigint/BigUnsigned.o /Users/wen/Projects/include/bigint/BigUnsignedInABase.o
maketest.hpp /Users/wen/Projects/include/bigint/BigInteger.hh /Users/wen/Projects/include/bigint/BigIntegerAlgorithms.hh /Users/wen/Projects/include/bigint/BigIntegerLibrary.hh /Users/wen/Projects/include/bigint/BigIntegerUtils.hh /Users/wen/Projects/include/bigint/BigUnsigned.hh /Users/wen/Projects/include/bigint/BigUnsignedInABase.hh /Users/wen/Projects/include/bigint/NumberlikeArray.hh
Compiles with:
g++ -O2 -c -I/Users/wen/Projects/include/bigint
Điều đó chứng minh làm mà biết những gì tôi muốn, nhưng khi nó được xây dựng nó hoàn toàn khác: c++
thay vì g++
?!
Cập nhật 2:
c++
gọi kêu vang, được cài đặt trên hệ thống của tôi.
Solution bởi Alex B:
Nhưng từ dòng lệnh biên soạn nó trông giống như Make đang cố gắng sử dụng quy tắc hậu tố tiềm ẩn, và bỏ qua quy tắc mẫu của bạn.
Tôi đã thử .SUFFIXES:
và có, báo cáo không tìm thấy quy tắc nào. Cảm ơn, tôi sẽ đi và tham khảo hướng dẫn sử dụng.
Lời khuyên của tôi? Kiểm tra nếu '" BigIntegerLibrary.hh "' tồn tại. –
Điều đó đã được nói với tôi nhiều lần; nó tồn tại. Vấn đề là làm cho không bao gồm CC_FLAGS đúng để vượt qua đường dẫn bao gồm trình biên dịch. –
Ồ. Và như vậy, chúng ta hãy xem ... –