开始使用跨平台C ++项目 [英] Getting started with a cross platform C++ project

查看:141
本文介绍了开始使用跨平台C ++项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开始一个c ++项目,我希望在同一版本的Eclipse(Linux)和vs2010中编译得很好,可以使用一些帮助。虽然许多方面可以单独使用Google,但我希望就如何处理整个问题提供建议。



例如,在哪里保存库来源,如何构建make文件,以及如何集成googletest(仅在googletest上找到一个新手教程是很困难的)。一个解决这些方面的教程的链接将是很棒的,或者一系列教程可以帮助。



我的背景是C#,我正在努力维护我的VS项目的清洁和组织。

解决方案

我已经完成了使用本机构建系统的跨平台项目在两个平台上(Windows上的vsproj文件和linux上的makefile),但是保持两个项目文件绝对是一个痛苦。所以,是的,我同意你应该尝试从一个坚实的跨平台构建实用程序开始的其他建议。 CMake或者可能 Boost build 看起来像体面的选择 - 可能还有很多其他



当涉及第三方库时,您将需要坚持经过验证的跨平台的东西。 Boost 是c ++最好的通用库(是的,你看到这里提到了几乎每个c ++线程...但这是因为它真的是一个很好的收集有用的东西)。对于XML,HTTP,图像库,UI - 有很好的跨平台选项 - 只要环顾一下,或者询问你是否有特定的要求。无论你做什么,不要使用CodeProject或其他仅针对Visual Studio 6进行测试的面向MS的站点的一些库,这只会导致苦难。大部分的GNU lib现在都建立在Windows上,所以你应该对这些东西是安全的。



尽管这将是诱人的,尽量减少平台 #ifdefs 在你的代码中 - 更愿意抽象图书馆中任何平台特定的东西,尽可能。



祝你好运! p>

I am starting a c++ project which I would like to compile equally well in Eclipse (Linux) and vs2010 from the same repository and could use some help getting started. While many of the aspects can individually be Google'd, I was hoping for advice on how to approach the problem on a whole.

For example, where to keep the library sources, how to structure the make file, and how to integrate googletest (finding a novice tutorial on googletest alone is hard). A link to a tutorial that addresses these aspects would be great, or a series of tutorials that together could help.

My background is in C# and I'm trying to maintain the "cleanness" and organization of my VS projects.

解决方案

I have done cross platform projects that used the "native" build systems on both platforms (vsproj files on windows and makefiles on linux), but it was definitely a pain to maintain both project files. So, yes, I would agree with the other suggestions that you should try to start with a solid cross platform build utility. CMake or possibly Boost build seem like decent options - likely there are many others.

When it comes to 3rd party libraries, you'll want to stick to stuff that is solidly tested cross platform. Boost is the best general purpose library for c++ (yes, you see it mentioned here in just about every c++ thread...but that's because it really is a nice collection of useful stuff). As for XML, HTTP, image libs, UI - there are all good cross platform options - just look around or ask here if you have specific requirements. Whatever you do, don't use some library from CodeProject or other MS oriented site that has only been tested with Visual Studio 6 - that will just lead to misery. Most of the GNU libs build on windows these days, so you should be reasonably safe with that stuff.

Although it will be tempting, try to minimize the platform#ifdefs in your code - prefer instead to abstract any platform specific stuff in a library wherever possible.

Good luck!

这篇关于开始使用跨平台C ++项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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