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

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

问题描述

我开始一个c ++项目,我想在Eclipse(Linux)和vs2010中同样编译同样的库,并可以使用一些帮助入门。虽然许多方面可以单独谷歌,我希望如何解决整个问题的建议。

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.

例如,保存库源代码,如何构造make文件,以及如何集成googletest(在googletest上单独寻找新手教程是很难的)。

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.

我的背景是在C#中,我试图维护这些方面的教程的链接是很好的,或者一系列的教程可以帮助。我的VS项目的清洁和组织。

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

推荐答案

我做过使用本地构建系统的跨平台项目在两个平台(vsproj文件在windows和makefiles在linux),但它绝对是一个痛苦,维护两个项目文件。所以,是的,我同意其他建议,你应该尝试开始一个坚实的跨平台构建实用程序。 CMake或可能 Boost版本看起来像体面的选项 - 可能还有很多其他选项。

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.

当涉及到第三方库,你会想要坚持测试跨平台的东西。 Boost 是c ++最好的通用库(是的,你看到它在每个c ++线程中提到...但是这是因为它 是一个很好的集合的有用的东西)。对于XML,HTTP,图像库,UI - 有所有很好的跨平台选项 - 只是看看或询问这里,如果你有特定的要求。无论你做什么,不要使用一些库从CodeProject或其他面向MS的网站,只有测试与Visual Studio 6 - 这只会导致苦难。现在大部分的GNU库都建立在windows上,所以你应该在这些东西上相当安全。

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.

虽然这将是诱人的,尝试最小化平台<$ c

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.

祝你好运!

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

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