c++ - 制作 : No rule to make a header file?

标签 c++ header makefile

我正在尝试使用名为 BigInt 的库创建一个项目。我的文件结构是:

/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

Fibonacci3 Makefile 截至

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)

bigint Makefile 截至(缩短)

# 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 \

但是,make 报告它找不到header 文件的规则?

make: *** No rule to make target `NumberlikeArray.hh', needed by `BigUnsigned.o'.  Stop.
[Finished in 0.0s with exit code 2]

这里发生了什么?标题应该被包含,而不是被编译,那么为什么 make 要求一个?

提前致谢!

解决方案:

不包含 makefile,而是在我自己的 makefile 中编译源代码。有效!再次感谢。

最佳答案

make 程序要求所有文件都在当前目录中。由于您将第二个 makefile 包含到当前 makefile 中,因此其中的所有文件也都是相对于当前目录的。您必须确保包含的 makefile 中的文件包含正确的路径。

关于c++ - 制作 : No rule to make a header file?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13934841/

相关文章:

html - 在使用 Bootstrap 粘性 header 时遇到问题

c++ - Tensorflow load graph c++ 示例中包含哪些 header ?

linux - osm2pgsql 未找到 Protobuf : Centos

makefile - "make install"和 "make altinstall"之间的细节差异

c++ - 光线追踪网格上的伪影黑线(使用 Embree)

c++ - c/c++ 在栈上分配

c++ - 循环与索引

c++ - boost::asio 服务器多进程

能够在浏览器上显示图像的 Python 服务器

linux - 绘制由 make 生成的 DAG?