visual-studio 如何从 Visual Studio 解决方案文件创建生成文件?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/2839221/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-22 11:59:04  来源:igfitidea点击:

How do I create a makefile from a Visual Studio solution file?

visual-studiomakefile

提问by Alex319

I have a Visual Studio project that uses a solution file to build it. I want to generate a makefile so that I can build it using the makefile instead of the solution file. (The reason I need to do this in case you are wondering is that I am incorporating my project into a larger software system that uses makefiles to build, and I want to be able to build the whole thing using the makefiles.)

我有一个使用解决方案文件来构建它的 Visual Studio 项目。我想生成一个生成文件,以便我可以使用生成文件而不是解决方案文件来构建它。(如果您想知道我需要这样做的原因是我正在将我的项目合并到一个使用 makefile 构建的更大的软件系统中,并且我希望能够使用 makefile 构建整个事情。)

Is there a way to automatically get the information from the Visual Studio solution and convert it into a makefile format, or do I need to do that manually?

有没有办法自动从 Visual Studio 解决方案中获取信息并将其转换为 makefile 格式,还是我需要手动执行此操作?

采纳答案by Hans Passant

This used to be possible in VC6, it had an option to generate a makefile from a .dsp project file. No more, the build process has changed too much to make this achievable.

这曾经在 VC6 中是可能的,它可以选择从 .dsp 项目文件生成生成文件。没有更多,构建过程发生了太多变化,无法实现。

Not a real problem, you can have the makefile invoke the vcbuild.exe tool, it builds a .vcproj project. Important switches you'll want to use in your makefile:

不是真正的问题,您可以让 makefile 调用 vcbuild.exe 工具,它会构建一个 .vcproj 项目。您要在 makefile 中使用的重要开关:

  • /clean: use that in your clean: target
  • /rebuild: use in your rebuild: target
  • /nocolor: makes build output look battleship gray like other build tools
  • /platform: selects the configuration you want to build (e.g: /platform:win32)
  • /clean: 在你的 clean: 目标中使用它
  • /rebuild:在你的重建中使用:目标
  • /nocolor:使构建输出像其他构建工具一样看起来是战舰灰色
  • /platform:选择你想要构建的配置(例如:/platform:win32)

For example:

例如:

vcbuild /platform:win32 example.vcproj release

Note that the build system got a major revision in VS2010, you'll use msbuild.exe instead to build the .vcxproj project.

请注意,构建系统在 VS2010 中进行了重大修订,您将使用 msbuild.exe 来构建 .vcxproj 项目。

回答by nc3b

Although I never used it, this might be an alternative. It's rather old and might not work well for new projects. It used to come with mingw but (don't know why) not anymore. Offtopic: Personally, if the project is not enormous, I would go with manually writing a Makefile.

虽然我从未使用过它,但这可能是一种选择。它相当陈旧,可能不适用于新项目。它曾经与 mingw 一起出现,但(不知道为什么)不再是了。Offtopic:就个人而言,如果项目不是很大,我会手动编写一个 Makefile。