Tools for c++ multiplatform projects

霸气de小男生 提交于 2020-01-06 02:58:18

问题


I am working with a c++ multi-platform project using visual studio 2010, there is a shared portion of code among all platforms, but there is a big portion that is dedicated to each one, I separate them using #if def, but it turns out that code maintenance become very though and the code is cluttered, in addition to problems like code does not compile with some defines turned on or off.

Is there any plugin or tool for visual studio that helps in developing multi-platform projects, for example hide code related to platform, or compile using different #defines turned on/off, check data types, .. ect.

I would be grateful if any one have a suggestion


回答1:


I do not know about such a plugin for VS, but since it's basically a Windows-only IDE, I doubt there are any. (But of course I could be wrong)

If you're looking for a good cross-platform build system, I'd look to CMake. It's powerful, easy to pick up and can generate build files for almost any popular IDE/toolchain (Visual Studio Solutions, Eclipse Projects, MinGW Makefiles, GNU Makefiles, etc).

It makes cross-platform development of larger projects a breeze!




回答2:


You could probably eliminate most of the platform dependent code if you switch to the Qt framework. You can keep to using VS with the Qt add-on and by using the platform abstractions of Qt you can target a number of different platforms with (nearly) identical code base. You get unbeatable platform support and portability:

  • Windows
  • Linux (Qt is native to KDE and future releases of Ubuntu)
  • MacOS
  • BB10 (Qt is native to BB10 too)
  • Embedded Linux
  • Android (coming next month)
  • iOS (next month too)
  • Jolla
  • Tizen

The APIs are also better IMO - less ugly and awkward, more consistent. Also QML (JSON style markup for building applications from C++ components using JS for glue code and value bindings) can significantly boost your productivity (up to 10 times without exaggerating). The Qt toolchain supports different kits (combination of library versions compilers and platforms) and multi-platform cross compilation.




回答3:


There is no "Tool" more than visual studio itself. Separate the code to different projects; Project for common code and project for each platform.

Don't forget to:

 1. Add reference to common project in all platform-dependent projects (so common project is compiled before platform project). 
 2. Add common project base to the common include directories of each target project.



来源:https://stackoverflow.com/questions/15496342/tools-for-c-multiplatform-projects

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!