简体   繁体   中英

C++ Cross platform development (Windows and Mac OS)

I've got new task to research the way of development C++ cross platform (Mac/Win) utility for our internal needs.

I've developed for 7 years using different "pink" languages like C# , Java , Managed C++. But in this task , the requirement is to support Mac , and .NET that is running on Mac , is really pain (Know this from other guys who did used this).

So I've started to think about C++ if it's possible to use C++ for Cross platform development. The application will no contain any GUI , but will contain a lot of System API calls , and a lot of business logic analysis.

Is there possible some library allowing to achieve such kind of Task ? Is it possible to do at all ?

Yes, you can write standard, ISO C++ and run the programs on both platforms.

When you need to implement some functionality using platform specific APIs (eg using Win32 on Windows and POSIX APIs on Mac OS) then what you do is write your own wrapper functions that abstract away the platform specific details, and then use that wrapper in the rest of your program.

Tools like CMake will allow you use Visual Studio to build the program on Windows and Xcode to build on the Mac without having to manually manage separate Visual Studio and Xcode project files.

If I understand your question properly, the only thing you need to develop cross platform c++ is to get the right compilers. You could use GCC on both platforms or even use 2 different project files for visual studio and xcode. That's up to you. Personally, I prefer GCC.

Regarding code itself, it depends on what you do with it. STD is available on both platforms (std::vector, std::string, etc) so code should compile properly on both platforms.

Edit: Btw, most platform specific stuff are available through open source code (like boost though I personally don't like boost that much). If needed, you could even look at other open source projects that are cross platform (ogre3d, etc).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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