To jest mylące. Mam Makefile:GNU Zrób zupełnie inny wynik
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)
powodzeniem skompilowany na początku, ale potem zatrzymał się bez powodu i to było wyjście:
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.
problem był, nawet nie powiedzieć jej zamiast tego użyj "C++" w pliku Makefile, ale "g ++". Ponadto, gdy wyczyściłem CC_FLAGS
, wciąż było tam. To tak, jakby Make miał własny pomysł.
Jeśli używam make print
wydrukować moje zmienne wydaje się być w porządku:
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
Każda pomoc lub porady będą mile widziane. Dzięki!
Aktualizacja
zaktualizowałem moją print
drukować oczekiwaną wykonanie kompilacji:
print:
@echo $(CC_FILES)
@echo $(OBJECTS)
@echo $(HEADERS)
@echo "Compiles with:"
@echo $(COMPILE) $(COMPILE_FLAGS) $(LD_FLAGS) $(CC_FLAGS)
Wynik:
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
To dowodzi, które sprawiają, że nie wie, co chciałem, ale kiedy buduje jest zupełnie inaczej: c++
zamiast g++
?!
Aktualizacja 2:
c++
wywołuje szczęk, zainstalowany w moim systemie.
Rozwiązanie przez Alex B:
Ale z wiersza polecenia kompilacji to wygląda Producent stara się używać niejawny regułę sufiks, a ignoruje regułę wzoru.
Próbowałem .SUFFIXES:
i tak, zgłosiło brak reguły. Dzięki, przejdę do instrukcji.
Moja rada? Sprawdź, czy istnieje "BigIntegerLibrary.hh". –
Powiedziano mi to wiele razy; istnieje. Problem polega na tym, że make nie zawierał poprawnie CC_FLAGS, aby przekazać ścieżkę dołączania do kompilatora. –
Oh. A więc, zobaczmy ... –