Windows 下使用makefile

写了一个简单的demo,测试使用:

// main.cpp
#include <iostream>
using namespace std;

int main() {
	cout << "Hello world" << endl;
	return 0;
}
// Makefile
target = test.exe
srcs = main.cpp

$(target) : $(srcs)
	cl -o [email protected] $^

在命令行执行nmake 提示:
Windows 下使用makefile
不认识 $^ ?修改Makefile如下:

// Makefile
target = test.exe
srcs = main.cpp

$(target) : $(srcs)
	cl -o [email protected] $**

执行nmake,结果如下:
Windows 下使用makefile


参考:nmake命令(windows下的makefile)