在一个生成文件中生成多个生成
Generate multiple builds in one makefile
每次运行make时,我都想让我的单元测试与我的项目一起构建。我尝试在我的Makefile中使用以下代码来做到这一点:
DEPS = Parallel.cpp Resistor.cpp Series.cpp Source.cpp
TEST = Parallel.cpp Resistor.cpp Series.cpp Test.cpp
resistor: $(DEPS)
g++ -std=c++11 -o resistor $(DEPS) -I. -g
test: $(TEST)
g++ -std=c++11 -o test $(TEST) -I. -g
然而,当我查看目录时,我只看到了/电阻器而不是/测验顺便说一句,任何以其他方式改进我的makefile的建议都是受欢迎的。
您可以添加以下规则作为Makefile
:中的第一条规则
all: resistor test
然后运行make
:
$ make
g++ -std=c++11 -o resistor Parallel.cpp Resistor.cpp Series.cpp Source.cpp -I. -g
g++ -std=c++11 -o test Parallel.cpp Resistor.cpp Series.cpp Test.cpp -I. -g
根据make
文件:
默认情况下,
make
以第一个目标(而不是其名称以"."开头)。
相关文章:
- 为什么两个不同的未命名名称空间可以共存于一个cpp文件中
- 挂起和取消挂起一个文件DLL
- C++-试图将函数指针推回到另一个CPP文件中的矢量时出错
- 输入到文件并输出到另一个文件,并将流文件传递给函数
- C++试图读取一个文件并输出到另一个文本文件
- 如何从另一个文件继承私有成员变量和公共函数
- 在 Windows 上,是否可以让 dll 在不使用 PATH 环境变量的情况下在另一个文件夹中查找依赖项?
- 如何打开并写入一个名称取自C++中字符串的文件
- 构建一个由C和C++文件组成的库
- c++多进程编写一个唯一的文件
- 如何使用CLion在Mac上创建一个新的.txt文件
- 如何将class.cpp和class.hpp编译为一个.o文件
- 写入文件会产生一个空文件或根本没有文件
- 如何将不同的可执行文件合并到一个窗口框架中进行编码?像浏览器一样
- 生成一个生成文件,该生成文件使用Automake在一个步骤中编译和链接所有源文件
- 为什么我的 heap.h 文件给我一个LNK2001错误?
- Pantheios 不使用 MFC 应用程序写入一个文件(一个 exe + 两个 DLL)
- 在C++中一次读取一个文件一个int
- 输入/输出文件(一个字母的大写)
- 如何使用两个预编译的头文件.一个用于托管代码,另一个用于非托管代码.xxx.PCH不是一个有效的预编译头文件