简体   繁体   English

最简单的方法是“移植”Visual Studio C ++项目以在Linux上编译?

[英]Easiest way to “port” a Visual Studio C++ project to compile on Linux?

Have been developing a Visual Studio (2012) C++ project and wondered what would be the most convenient way of being able to copy it over to Linux so that I could re-compile the whole project there? 一直在开发一个Visual Studio(2012)C ++项目,并想知道什么是最方便的方法将它复制到Linux,以便我可以在那里重新编译整个项目? Assume the C++ is platform-independent. 假设C ++与平台无关。

Would it be a case of copying all the .h and .cpp files manually in to one folder, copy that folder to Linux and then somehow creating a script (makefile?) which controls how the files are compiled? 是手动将所有.h和.cpp文件复制到一个文件夹,将该文件夹复制到Linux然后以某种方式创建一个控制文件编译方式的脚本(makefile?)的情况? I'm not too sure if a makefile is what I require- but any mechanism so that I can compile the whole project from one command on the terminal? 我不太确定makefile是否是我需要的 - 但是任何机制都可以让我从终端上的一个命令编译整个项目?

For the physical part, the easiest solution is to just grab the sources from your Version Control System. 对于物理部分,最简单的解决方案是从版本控制系统中获取源代码。 That will take care of the \\r\\n -> \\n translation in your .cpp and .h files. 这将处理.cpp和.h文件中的\\r\\n - > \\n转换。

On the linux side, pretty much any build tool is superior to raw make . 在linux方面,几乎任何构建工具都优于原始make make is really the assembly language of build systems; make实际上是构建系统的汇编语言; your tool might produce a makefile as an intermediary but don't try to maintain that. 您的工具可能会生成一个makefile作为中介,但不要尝试维护它。

Yes, copy the files (or as @MSalters says - checkout a fresh copy) then construct an alternative .vcxproj for the Linux build tools. 是的,复制文件(或者@MSalters说 - 签出一份新副本),然后为Linux构建工具构建一个替代的.vcxproj。 Note that the Visual Studio project file is really just a very fancy type of makefile. 请注意,Visual Studio项目文件实际上只是一种非常奇特的makefile类型。

A makefile at its simplest is just a list of files (or file types even) and a command for running on them. 最简单的makefile只是一个文件列表(或文件类型甚至)和一个用于在它们上运行的命令。 Once you have that written up, building is as simple as running MSBuild against a .sln file. 一旦你写完了,构建就像对.sln文件运行MSBuild一样简单。

So you need to decide which build system to use on Linux - there's CMake which is a makefile-generator, and several other systems available. 所以你需要决定在Linux上使用哪个构建系统 - 那里有CMake,它是一个makefile-generator, 还有其他几个系统可用。

Someone has made a tool that parses the VS project file and can generate a makefile from it, but it doesn't support VS2012 (you can fix this though, contribute) 有人制作了一个解析VS项目文件并可以从中生成makefile 的工具 ,但它不支持VS2012(你可以解决这个问题,贡献)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM