简体   繁体   English

是否可以在Windows和Mac OS上都可以用C ++开发桌面应用程序?

[英]Can a desktop app be developed in C++ that would work on both Windows and Mac OS?

I am trying to save some money and develop a desktop application that would work on both Windows and a Mac OS. 我试图节省一些钱,并开发一种在Windows和Mac OS上均可使用的桌面应用程序。 Is this possible? 这可能吗? Can we do it in C++ and then, with a few fixes and tweaks, still reuse the same app on both OS? 我们可以用C ++做到吗,然后经过一些修复和调整,仍然可以在两个OS上重用同一应用程序?

Yes this is possible. 是的,这是可能的。 Some code may differ as there are differences in the operating systems. 某些代码可能会有所不同,因为操作系统有所不同。

  • You should use a common library for GUI such as Qt: http://qt.nokia.com/ 您应该为GUI使用通用库,例如​​Qt: http//qt.nokia.com/
    It is worth noting that Qt brings much more cross-platform features to the table, so familiarize yourself with it. 值得注意的是,Qt为表带来了更多的跨平台功能,因此请熟悉一下它。
  • There will be some differences to handle such as 会有一些差异需要处理,例如
    • File paths (C: doesn't exist on Mac, \\ and / are path separators, etc) 文件路径(C:在Mac上不存在,\\和/是路径分隔符,等等)
    • File endings differ (CrLf in Windows, Lf in Mac) 文件结尾不同(在Windows中为CrLf,在Mac中为Lf)
  • You need to compile to two different target CPU's. 您需要编译为两个不同的目标CPU。 Most C++ compilers can do this. 大多数C ++编译器都可以做到这一点。
  • The same code can be used for both, you just define regions to be (or not be) included depending on what OS the compiler is targeting. 两种代码都可以使用相同的代码,您只需根据编译器所针对的OS定义要包含(或不包含)区域。

Just Google a cross-os development guide, looooots of people has done this before. 只是Google作为跨操作系统的开发指南,许多人以前就已经做到了。 :) :)

It may not be relevant, but still worth noting (because you said "save money"), that both Java and the Mono Project (.Net, Qt) allows you to write cross platform applications with limited skills about the underlying platform. 可能不相关,但仍然值得注意(因为您说了“省钱”),Java和Mono Project (.Net,Qt)都允许您编写跨平台应用程序,但对底层平台的技能有限。 They are higher level language which in general are considered a time saver (but that is a separate discussion.) 它们是高级语言,通常被认为是节省时间的语言(但这是一个单独的讨论。)

Expanding on my comment: 扩展我的评论:

Don't . 别这样

Write your library code in portable C++; 用可移植的C ++编写您的库代码; putting as much as possible of the functionality in the library, making sure you study the platform-specific APIs (probably Cocoa and .NET) as you go, so the interfaces to the library are at least moderately suitable for either. 将尽可能多的功能放到库中,确保在学习过程中研究特定于平台的API(可能是Cocoa和.NET),因此库的接口至少适度适合这两种接口。

Then wrap your library in native binaries; 然后用本地二进制文件包装您的库; ensuring that you pay attention to how applications are supposed to look on each platform, as well as the feel of them. 确保您注意应用程序在每个平台上的外观以及它们的感觉。

Building an application that looks like an X11 application and does everything in a manner somewhere between a Gnome application, a KDE application, an OS X application and a Windows application will really hurt user experience. 构建一个看起来像X11应用程序并以Gnome应用程序,KDE应用程序,OS X应用程序和Windows应用程序之间的某种方式进行所有操作的应用程序, 确实会损害用户体验。

Badly . 严重的

WxWidgets WxWidgets

This question gets asked a lot , see also: this question , this one and this one amongst others. 这个问题被问了很多 ,另请参阅: 这个问题这个 问题以及这个 问题

Coming in late to the party here! 迟到这里来参加聚会!

I'm in the last stages of finishing a cross-platform, commercial application (OS/X and Windows for right now, conceivably Linux or iOS later). 我正处于完成跨平台的商业应用程序的最后阶段(目前仅适用于OS / X和Windows,可以考虑稍后使用Linux或iOS)。

We're using an open-source, cross-platform C++ development library called Juce, and I can't speak highly enough of it. 我们正在使用一个名为Juce的开源,跨平台C ++开发库,我对此评价不够。 It's extremely full-featured, the code is solid and high-quality, and you can apparently build for Windows, OS/X, Linux, iOS and Android from the same codebase (we've only tried the first two, but other developers are apparently reporting success for the other platforms). 它功能非常强大,代码坚固且高质量,您显然可以从同一代码库为Windows,OS / X,Linux,iOS和Android进行构建(我们仅尝试了前两个,但其他开发人员显然报告了其他平台的成功)。

What's particularly nice is that lead developer is very active on his bulletin boards and extremely responsive to trouble reports. 特别令人高兴的是,首席开发人员在公告板上非常活跃,并且对故障报告反应非常快。

Also, you can license the library under GPL, and they also have a very reasonably priced commercial license. 另外,您可以根据GPL许可该库,而且它们还具有价格非常合理的商业许可。

Juce is very popular amongst people doing digital audio applications - indeed, to my best knowledge many or perhaps most of the top commercial digital audio apps use this system - but it's very full-featured and extremely fast and should be considered a top candidate for any cross-platform development application. Juce在从事数字音频应用程序的人们中非常受欢迎-实际上,据我所知,许多顶级商业数字音频应用程序可能都使用了该系统-但它功能齐全且速度极快,因此应被认为是任何应用程序的最佳选择跨平台开发应用程序。

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

相关问题 Windows和Mac OS中的C ++字符串比较 - C++ string compare in Windows and Mac OS C ++程序可以在Mac OS上运行吗? - Can a C++ program run on Mac OS? 适用于UWP和Classic桌面的C ++通用Windows DLL - C++ Universal Windows DLL for both UWP and Classic Desktop 我可以在Windows 7上安装Windows 8 SDK来编译C ++桌面应用程序(没有Metro组件)吗? - Can I install Windows 8 SDK on Windows 7 to compile C++ desktop app (no Metro stuff)? C ++跨平台开发(Windows和Mac OS) - C++ Cross platform development (Windows and Mac OS) 我可以使用 C++/WinRT 编写一个 DLL 以供 Windows 桌面应用程序(不是 UWP)或作为 Unity 插件使用吗? - Can I write a DLL with C++/WinRT to be consumed by a windows desktop app(not UWP) or as a Unity plugin? 无法在Linux上编译C ++代码,但可以在Mac OS上编译 - Cannot compile C++ code on Linux, but can on Mac OS 当子窗口成为 C# 桌面应用程序的子窗口时,C++ Windows 桌面应用程序中的持续闪烁? - Constant flickering in C++ Windows desktop app when a child window is made the child of a C# desktop app? 如何将基于qt的应用程序(在Mac上开发)部署到Windows? - How to deploy a qt based app(developed on Mac) to Windows? 在 Flutter Windows 桌面应用程序中使用 C++ DLL - Using a C++ DLL in Flutter Windows desktop app
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM