Make: No rule to make a header file?
c++, header, makefile
Solution
The `make` program expects all files to be in the current directory. Since you include the second makefile into the current makefile, all files in that are relative to the current directory as well. You have to make sure that the files in the included makefile contains the correct paths.
Problem
I am trying to make a project using a library named BigInt. My file structure is: ``` /Users/wen/Projects/challenge/fibonacci3/fibonacci3.cpp /Users/wen/Projects/challenge/fibonacci3/Makefile /Users/wen/Projects/include/bigint/<.cc files and .hh files> /Users/wen/Projects/include/bigint/Makefile ``` The Fibonacci3 Makefile is as of ``` LD_FLAGS = CC_FLAGS = # Include libraries include /Users/wen/Projects/include/bigint/Makefile # Build object files %.o: %.cc %.cpp $(library-cpp) g++ -c -o $@ $(CC_FLAGS) # Link object files fibonacci3: fibonacci3.o $(library-objects) g++ -o $@ $(LD_FLAGS) ``` and the bigint Makefile is as of (shortened) ``` # Mention default target. all: # Implicit rule to compile C++ files. Modify to your taste. %.o: %.cc g++ -c -O2 -Wall -Wextra -pedantic $< # Components of the library. library-cpp = \ BigUnsigned.cc \ BigInteger.cc \ BigIntegerAlgorithms.cc \ BigUnsignedInABase.cc \ BigIntegerUtils.cc \ library-objects = \ BigUnsigned.o \ BigInteger.o \ BigIntegerAlgorithms.o \ BigUnsignedInABase.o \ BigIntegerUtils.o \ library-headers = \ NumberlikeArray.hh \ BigUnsigned.hh \ BigInteger.hh \ BigIntegerAlgorithms.hh \ BigUnsignedInABase.hh \ BigIntegerLibrary.hh \ ``` however, `make` reports that it could not find a rule for a header file? ``` make: *** No rule to make target `NumberlikeArray.hh', needed by `BigUnsigned.o'. Stop. [Finished in 0.0s with exit code 2] ``` What is happening here? Headers are supposed to be included, not compiled, so why is make asking for one? Thanks in advance! Solution: Instead of including the makefile, compile the sources in my own makefile. It worked! Thanks again.