mingw 可以构建一个 Visual Studio-2010 项目吗?
我有一个 Visual Studio-2010 项目,其中包含大量源文件和头文件。现在我需要在最新的 Debian GNU/Linux 下自动构建这个项目。所以我选择使用MinGW。但我需要这个视觉工作室项目的 makefile。有没有一种简单的方法可以将 vs 项目转换为 makefile?或者 MinGW 可以直接用附加的包或库构建一个 Visual Studio 项目吗?任何想法将不胜感激。
I have a visual studio-2010 project which contains lots of source files and header files. Now I need to autobuild this project under the latest Debian GNU/Linux. So I choose to use MinGW. But I need a makefile of this visual studio project. Is there a easy way to translate a vs project into a makefile? Or MinGW can directly build a visual studio project with additional packages or libraries? Any ideas will be appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果您想将程序的构建永久移植到 GNU/Linux,我建议切换到自动工具(autoconf 和 automake)。自动工具非常普遍,并且具有出色的交叉编译支持。 (另一方面,也因怪异而赢得了声誉。)虽然我知道 VS 项目没有自动翻译,但单个程序的编译可以像查找所有源文件和头文件一样简单设置,在 Makefile.am 中适当列出它们并为 Windows 对象编写规则。
如果向 MinGW 的过渡不是一成不变的,或者可能会出现持续的两个编译器构建场景,请像评论者建议的那样使用 cmake。虽然我一直发现 CMake 是非维护者构建的一大难题(对于开源软件来说很常见),但它在生成各种构建描述文件(如 Makefile 和 VS 项目)方面享有良好的声誉。
无论哪种方式,您都必须手动转换您的项目。对于正常的项目结构来说这可能很容易,但必须完成。
If you want to port building of your program permanently to GNU/Linux, I'd recommend to switch to the autotools (autoconf and automake). The autotools are very widespread and have excellent cross-compilation support. (on the other hand, also a somewhat earned reputation for weirdness.) While there is no auto-translation from VS projects I'm aware of, compilation of a single program can be as simple to set up as finding all source and header files, listing them in the Makefile.am appropriately and writing a rule for Windows objects.
If the transition to MinGW isn't written in stone or a continuing two-compiler build scenario is likely, go with cmake like the commenters suggested. While I've always found CMake to be a major pain for non-maintainer builds (common for open-source software), it has a good reputation for generating all kinds of build description files like Makefiles and VS projects.
One way or the other, you'll have to convert your project by hand. It can be quite easy for a normal project structure, but it has to be done.
我不知道有任何工具链能够开箱即用地执行此操作。 CMake(以及所有其他元 makefile 生成器)仅提供单向转换:它们可以生成 Visual Studio 项目/解决方案一次,但无法自动与 VS/MSBuild 配置中所做的更改同步。编写和维护 CMake(或 PreMake 或其他)配置是一件痛苦的事情,只有当您的主要开发平台位于 Microsoft 平台之外的任何地方时,它才有意义。
不过,还有一个有趣的替代方案: xbuild - MSBuild 的一个端口,它是背后的构建系统VS的智力。理论上,可以扩展系统以支持 Visual Studio 生成的 MSBuild 配置,并为其他平台上的正确 C++ 工具链定义转换规则(甚至以双向方式)。与 autotools/make 相比,MSBuild/XBuild 的声明性、基于 XML 的性质是一个巨大的胜利,autotools/make 花费了我太多的时间,给我的开发人员的生活带来了不便。 MSBuild/XBuild 都是作为纯托管框架实现的,具有精心设计的架构,因此扩展非常容易实现。当然,只有当您(或您的公司)认真考虑大规模跨平台支持时,这才有回报。
I do not know of any tool-chain which is capable of doing this out of the box. CMake (and all the other meta makefile generators) only offer a one-way conversion: they can generate a Visual Studio project/solution once, but there is no way to automatically synchronize with changes made in VS/MSBuild configurations. Writing and maintaining CMake (or PreMake or whatever) configurations is a pain and it only makes sense, if your primary development platform is anywhere outside the Microsoft platform.
There is an interesting alternative though: xbuild - a port of MSBuild which is the build system behind the intelligence of VS. Theoretically, one could extend the system to support MSBuild configurations generated by Visual Studio and define conversion rules for proper C++ tool-chains on other platforms (even in a two-way manner). The declarative, XML based nature of MSBuild/XBuild is a huge win compared to autotools/make which have costed me far too much time and inconvenience in my developer's life. MSBuild/XBuild are both implemented as a purely managed framework with well designed architecture so that extensions are quite easy to implement. Of course, this only pays off if you (or your company) are seriously thinking about large scale cross platform support.