简体   繁体   English

提升C ++开源项目的依赖性?

[英]Boost dependency for a C++ open source project?

Boost is meant to be the standard non-standard C++ library that every C++ user can use. 升压意味着是标准非标准C ++库,每一个C ++用户可以使用。 Is it reasonable to assume it's available for an open source C++ project, or is it a large dependency too far? 假设它可用于开源C ++项目是否合理,或者它是一个很大的依赖?

Basically your question boils down to “is it reasonable to have [free library xyz] as a dependency for a C++ open source project.” 基本上你的问题归结为“将[免费库xyz]作为C ++开源项目的依赖项是否合理。”

Now consider the following quote from Stroustrup and the answer is really a no-brainer: 现在考虑一下Stroustrup的以下引用,答案真的很简单:

Without a good library, most interesting tasks are hard to do in C++; 没有一个好的库,大多数有趣的任务在C ++中很难做到; but given a good library, almost any task can be made easy 但是如果有一个好的图书馆,几乎任何任务都可以轻松完成

Assuming that this is correct (and in my experience, it is) then writing a reasonably-sized C++ project without dependencies is downright unreasonable. 假设这是正确的(根据我的经验,它是)然后编写一个没有依赖关系的合理大小的C ++项目是完全不合理的。

Developing this argument further, the one C++ dependency (apart from system libraries) that can reasonably be expected on a (developer's) client system is the Boost libraries. 进一步发展这个论点,可以在(开发人员)客户端系统上合理预期的一个 C ++依赖(除了系统库)是Boost库。 I know that they aren't but it's not an unreasonable presumption for a software to make. 知道它们不是,但这不是一个软件无法推定的假设。

If a software can't even rely on Boost, it can't rely on any library. 如果一个软件甚至不能依赖Boost,它就不能依赖任何库。

Take a look at http://www.boost.org/doc/tools.html . 请查看http://www.boost.org/doc/tools.html Specifically the bcp utility would come in handy if you would like to embed your boost-dependencies into your project. 具体来说,如果您想将boost-dependencies嵌入到项目中, bcp实用程序会派上用场。 An excerpt from the web site: 网站摘录:

"The bcp utility is a tool for extracting subsets of Boost, it's useful for Boost authors who want to distribute their library separately from Boost, and for Boost users who want to distribute a subset of Boost with their application. “bcp实用程序是一个用于提取Boost子集的工具,它对于希望与Boost分开分发其库的Boost作者以及希望将Boost子集与其应用程序一起分发的Boost用户非常有用。

bcp can also report on which parts of Boost your code is dependent on, and what licences are used by those dependencies." bcp还可以报告您的代码所依赖的Boost的哪些部分,以及这些依赖项使用的许可证。“

Of course this could have some drawbacks - but at least you should be aware of the possibility to do so. 当然这可能有一些缺点 - 但至少你应该意识到这样做的可能性。

I used to be extremely wary of introducing dependencies to systems, but now I find that dependencies are not a big deal. 我曾经非常谨慎地将依赖项引入系统,但现在我发现依赖项并不是什么大问题。 Modern operating systems come with package managers that can often automatically resolve dependencies or, at least,make it very easy for administrators to install what is needed. 现代操作系统带有包管理器,它们通常可以自动解决依赖关系,或者至少使管理员可以轻松安装所需的东西。 For instance, Boost is available under Gentoo-Postage as dev-libs/boost and under FreeBSD ports as devel/boost. 例如,Boost在Gentoo-Postage下可用作dev-libs / boost,在FreeBSD下可用作devel / boost。

Modern open source software builds a lot on other systems. 现代开源软件在其他系统上构建了很多。 In a recent study , by tracking the dependencies of the FreeBSD packages, we established that the 12,357 ports packages in our FreeBSD 4.11 system, had in total 21,135 library dependencies; 最近的一项研究中 ,通过跟踪FreeBSD软件包的依赖关系,我们确定了FreeBSD 4.11系统中的12,357个端口软件包,共有21,135个库依赖项; ie, they required a library, other than the 52 libraries that are part of the base system, in order to compile. 也就是说,他们需要一个库,而不是作为基本系统一部分的52个库,以便编译。 The library dependencies comprised 688 different libraries, while the number of different external libraries used by a single project varied between 1 and 38, with a mode value of 2. Furthermore, 5,117 projects used at least one external library and 405 projects used 10 or more. 库依赖项包含688个不同的库,而单个项目使用的不同外部库的数量在1到38之间,模式值为2.此外,5,117个项目至少使用一个外部库,405个项目使用10个或更多。

In the end the answer to your question will come from a cost versus benefit analysis. 最后,您的问题的答案将来自成本与收益分析。 Is the benefit of re-using a mature, widely used, reviewed, and tested library like Boost and larger than the low and falling cost of a dependency? 重用一个成熟的,广泛使用的,经过审查和测试的库(如Boost)的好处是否大于依赖的低成本和低成本? For any non-trivial use of Boost's facilities the answer is that you should go ahead and use Boost. 对于任何非常重要的Boost设施使用,答案是你应该继续使用Boost。

KDE also depends on Boost. KDE也依赖于Boost。

However it mostly depends on your goals, and even more so on your target audience, rather than the scope of your project. 但是,它主要取决于您的目标,甚至取决于您的目标受众,而不是您的项目范围。 for example TinyJSON (very small project), is almost 100% Boost, but thats fine because the API it provides is Boost-like and targeted at Boost programmers that need JSON bindings. 例如TinyJSON(非常小的项目),几乎是100%Boost,但这很好,因为它提供的API类似于Boost,并且针对需要JSON绑定的Boost程序员。 However many other JSON libraries don't use Boost because they target other audiences. 但是,许多其他JSON库不使用Boost,因为它们针对其他受众。

On the other hand I can't use Boost at work, and I know lots of other developers (in their day jobs) are in the same boat. 另一方面,我不能在工作中使用Boost,而且我知道很多其他开发人员(在他们的日常工作中)都在同一条船上。 So I guess you could say if your Target is OpenSource, and a group that uses Boost, go ahead. 所以我猜你可以说你的Target是OpenSource,还是一个使用Boost的组,请继续。 If you target enterprise you might want to think it over and copy-paste just the necessary parts from Boost(and commit to their support) for your project to work. 如果您以企业为目标,您可能需要仔细考虑并复制粘贴Boost中的必要部分(并提交他们的支持)以使您的项目正常工作。

  • Edit: The reason we can't use it at work is because our software has to be portable to about 7 different platforms and across 4 compilers. 编辑:我们不能在工作中使用它的原因是因为我们的软件必须可以移植到大约7个不同的平台和4个编译器。 So we can't use boost because it hasn't been proven to be compatible with all our targets, so the reason is a technical one. 所以我们不能使用boost,因为它还没有被证明与我们所有的目标兼容,所以原因是技术性的。 (We're fine with the OpenSource and Boost License part, as we use Boost for other things at times) (我们对OpenSource和Boost许可证部分很好,因为我们有时会将Boost用于其他事情)

It depends. 这取决于。 If you're using a header file only defined class template in Boost - then yes go ahead and use it because it doesn't suck in any Boost shared library, as all the code is generated at compile time with no external dependencies. 如果您在Boost中使用头文件仅定义了类模板 - 那么请继续使用它,因为它不会吸入任何Boost共享库,因为所有代码都是在编译时生成的,没有外部依赖。 Versioning problems are a pain for any shared c++ library, and Boost is not immune from this, so if you can avoid the problem altogether it's a good thing. 版本控制问题对于任何共享的c ++库来说都是一种痛苦,而Boost并没有免疫这个问题,所以如果你完全可以避免这个问题,这是一件好事。

I would say yes. 我会说是的。 Both Mandriva ( Red Hat based) and Ubuntu ( Debian based) have packages for the Boost libriaries. Mandriva (基于Red Hat )和Ubuntu(基于Debian )都有Boost libriaries的软件包。

The benefits of using boost when writing C++ code that they significantly outweigh the extra complexity of distributing the open source code. 在编写C ++代码时使用boost的好处明显超过了分发开源代码的额外复杂性。

I work on Programmer's Notepad and the code takes a dependency on boost for test, smart pointers, and python integration. 我在Programmer的记事本上工作,代码依赖于测试,智能指针和python集成的boost。 There have been a couple of complaints due to the requirement, but most will just get on with it if they want to work on the code. 由于这个要求,有一些投诉,但如果他们想要处理代码,大多数人都会继续投诉。 Taking the boost dependency was a decision I have never regretted. 采取提升依赖是我从未后悔的决定。

To make the complexity slightly less for others, I include versioned pre-built libraries for boost python so that all they need to do is provide boost in their include directories. 为了使其他人的复杂性略微降低,我为boost python添加了版本化的预构建库,这样他们所需要做的就是在include目录中提供boost。

我认为Boost提供的广泛功能,正如您所说,它是标准的非标准C ++库,证明它是一种依赖。

Unfortunately yes, for ubuntu they're readily available but for RHEL 4&5 I've almost always ended up making them from tarballs. 不幸的是,对于ubuntu,它们很容易获得,但对于RHEL 4和5,我几乎总是最终用tarball制作它们。 They're great libraries, just really big... like using a rail spike when sometimes all you really need is a thumbtack. 他们是伟大的图书馆,真的很大......就像使用铁轨尖峰有时你真正需要的只是一个图钉。

It all depends on the way you're going to use Boost. 这一切都取决于你将使用Boost的方式。 As Diomidis said, if you're going to use some non-trivial facilities from Boost, just go ahead. 正如迪奥米迪斯所说,如果你打算使用Boost的一些非平凡的设施,那就继续吧。 Using libraries is not a crime. 使用图书馆不是犯罪。

Of course, there are many people who prefer not to use Boost, because introducing new dependencies has always some cons and extra worries, but in an open source project... in my opinion it's even alright to use them if you just want to learn them or improve your skills on them. 当然,有很多人不喜欢使用Boost,因为引入新的依赖关系总是有一些缺点和额外的担忧,但在一个开源项目中...在我看来如果你只是想学习它甚至可以使用它们他们或提高你的技能。

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

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