如何将Visual Studio C ++编译为linux和os-mac [英] How to Compile Visual studio C++ to linux and os-mac

查看:87
本文介绍了如何将Visual Studio C ++编译为linux和os-mac的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我可以编译现有的C ++代码以在os-mac asnd linux中运行吗?

最好的保护者
abzadeh

Can I Compile my existing C++ Code to run in os-mac asnd linux?

Best reguards
abzadeh

推荐答案

我认为这取决于您是否在现有代码中使用了Windows特定的东西.

最后,在检查您的应用程序是否特定于Windows之后,您所能做的就是尝试在您选择的平台上编译该应用程序,然后查看它是否成功.如果在编译或执行过程中发现故障点,则必须弄清楚为什么以及是否正在做一些可以跨平台工作的工作.取决于出了什么问题,这可能会非常耗时.
I''d think that would depend on whether you used any Windows-specific stuff in your existing code.

In the end, after you''ve looked for whether your app is Windows-specific, all you can do is try to compile it on the platform of your choice and see whether it succeeds or fails. If you find failure points in compilation or in execution, you have to figure out why and whether you''re doing something that can be made to work cross-platform. Depending on how much goes wrong, this could be quite time-consuming.


回答后续问题:适用于Windows,Linux和Mac的新UI.

首先,有几种不同的Linux平台;一切都基于X-Windows,最上面是一个或另一个带有其API(KDE,Gnome)的Windows管理器,还有多平台的Qt和Gtk +(在Windows上也都可以使用,对于最后),以及基于CLI的:.NET(在Windows上),Mono(许多其他平台). .NET/Mono基于CLI,ECMA和ISO标准,因此这是最可靠的,但这远不止UI,这是管理内存,IL JIT编译的代码,很多东西,如果是Windows-特定的但非标准的零件也得到Mono的广泛支持. .NET/Mono可以使用在本机平台上编写的共享库,因此这对您有用.

因此,如果您从一开始就使用以下其中一种用户界面,则可以首先进行Windows + Linux + Mac +更多开发:Qt,Gtk + 、. NET,Mono,.NET +本机或Mono +本机.如果您这样做的话,那么您现在就可以使用Linux.另外,您可以通过两种方式使用.NET +本机C ++:1)使用P/Invoke链接到.NET应用程序的本机C ++ DLL,2)混合模式(托管+非托管)的C ++和C ++/CLI项目,可以将两种方式混合使用在同一个项目和同一个可执行模块中易于互操作;它可以扮演双重角色:.NET Assembly的主要模块和本机DLL.

你现在可以做什么?您可以使用Windows启动Linux就绪的开发.这种方法对您来说将是最方便的.您当然需要将所有通用代码和特定于应用程序的代码保持其本机形式,并与UI隔离.您可以在Windows上进行所有开发,并定期在Linux(或其他OS)上对其进行测试.首先,您需要选择UI应用程序的主要平台:托管平台或本机平台,本机平台是从Qt或Gtk中选择的.我不能建议在我很久以前转移到托管平台并且从未使用Qt,Gtk,Gnome或类似的东西进行开发时选择哪个平台(我很早以前在Linux上开发,在那些API创建之前,后来才开发)单声道).对于.NET/Mono,您还应该从相同的平台中进行选择,并且可以使用System.Windows.Forms进行开发.我这样做,并且我的应用程序在Linux上运行,而无需重新编译.当然,对于本机(但可移植)项目,您将需要在每个平台上重新编译它们. .NET/Mono遵循字节码(IL),最后仅在运行时根据方法针对本机CPU代码进行编译.

也许,您甚至没有希望使用多平台应用程序.我不建议您完全切换到Linux.如果您曾经使用过Windows,那么最好还是继续使用它,而最好使用多操作系统UI.正如我试图解释的那样,这是完全可行的.

那么,你能说什么呢?决定,决定...

—SA
Answering the follow-up Question: new UI for Windows, Linux and Mac.

First, there are several different platforms for Linux; all is based on X-Windows, on top of it there is one or another Windows Manager with their APIs (KDE, Gnome), there is multi-platform Qt and Gtk+ (both available on Windows as well, can be a good point for your) and finally, and CLI-based: .NET (on Windows), Mono — many other platforms). .NET/Mono is based in CLI, ECMA and ISO standard, so this is most solid, but this is much more than UI, this is manages memory, IL JIT-compiled code, lots of goodies, big part if it is Windows-specific, but even non-standard parts are vastly supported by Mono. .NET/Mono can use shared libraries written on native platform, so this will work for you.

So, you could do Windows + Linux + Mac +more development in first place if you used from the very beginning for UI one of the following: Qt, Gtk+, .NET, Mono, .NET + native or Mono + native. If you did so, you would be Linux-ready by now. Also, you could use .NET + native C++ in two ways: 1) Native C++ DLLs linked to .NET applications using P/Invoke, 2) Mixed-mode (managed+unmanaged) C++ and C++/CLI project which can mix up two words an easily interoperate in the same project and same executable module; it would be able to play dual role: main module of .NET Assembly and native DLL.

What can you do now? You can start Linux-ready development using Windows. This approach will be the most convenient for you. You certainly need to keep all your universal and application-specific code in its native form and isolated from UI. You can do all development on Windows and test it on Linux (or other OS) on a regular basis. First you need to choose main platform for UI application: managed or native and for native, chose from Qt or Gtk. I cannot advise which one to pick up for native platform as I moved to managed long time ago and never developed with Qt, Gtk, Gnome or something like that (I developed on Linux long time ago, before those APIs were created and later developed only for Mono). For .NET/Mono, you also should choose from the same platforms, plus you can develop using System.Windows.Forms. I do this, and my applications are run on Linux without recompilation. For native (but portable) project you would need to recompile it all in each platform, of course. .NET/Mono complies in byte-code (IL) and finally compiles for native CPU codes only during run-time, on per-method basis.

Maybe, you did not even hope for multi-platform application. I would not advice you to switch to Linux completely. If you used to Windows, it’s much better to stay with it and prefer multi-OS UI. As I tried to explain, this is quite feasible.

So, what can you say? Decisions, decisions…

—SA


这篇关于如何将Visual Studio C ++编译为linux和os-mac的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆