【问题标题】:how to write makefile for c++ vs proje如何为 c++ vs proje 编写 makefile
【发布时间】:2016-12-14 20:32:48
【问题描述】:

我需要为在 windows 上运行的 c++ visual-studio 项目编写一个 makefile。 我只有 5 个文件需要编译:

main,  Board.cpp, Board.h, Node.cpp, Node.h

我想在 cmd 中使用“make”命令并全部编译。 我不知道如何为此编写正确的makefile,在搜索时我发现了这个Write makefile for .cpp and .hpp c++,但这不是我的情况.. 帮忙??

【问题讨论】:

  • 你将如何在命令行上执行(即*没有 Make)?
  • 听说有“nmake”之类的,所以说我要使用“make”

标签: c++ windows visual-studio makefile compilation


【解决方案1】:

最简单的应该是

all:
    g++ main.cpp Board.cpp Node.cpp

【讨论】:

  • 不需要编译所有头文件?该makefile是否一定适用于所有Windows操作系统计算机?顺便说一句,如果我需要从外部 txt 文件读取或写入,makefile 是否重要?
  • 头文件永远不会被编译,是的,甚至像 linux 这样的其他系统也是如此。读/写外部文件没关系
  • 请注意问题上的标签.... Visual Studio 不附带 g++。
  • 你可以用任何编译器替换g++
  • 其实你使用哪个编译器并不重要,Visual Studio 有自己的编译器。您可以通过将 g++ main.cpp Board.cpp Node.cpp 替换为 msbuild your_project.sln /Flags 直接构建 Visual Studio 解决方案,如下所述:stackoverflow.com/questions/498106/…
猜你喜欢
  • 2013-12-22
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2021-03-12
  • 2011-02-15
相关资源
最近更新 更多