Boost dependency for a C++ open source project?

2020-05-19 04:59发布

Boost is meant to be the standard non-standard C++ library that every C++ user can use. Is it reasonable to assume it's available for an open source C++ project, or is it a large dependency too far?

10条回答
闹够了就滚
2楼-- · 2020-05-19 05:24

The benefits of using boost when writing C++ code that they significantly outweigh the extra complexity of distributing the open source code.

I work on Programmer's Notepad and the code takes a dependency on boost for test, smart pointers, and python integration. 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.

查看更多
Ridiculous、
3楼-- · 2020-05-19 05:29

Take a look at 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. 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 can also report on which parts of Boost your code is dependent on, and what licences are used by those dependencies."

Of course this could have some drawbacks - but at least you should be aware of the possibility to do so.

查看更多
家丑人穷心不美
4楼-- · 2020-05-19 05:33

Basically your question boils down to “is it reasonable to have [free library xyz] as a dependency for a C++ open source project.”

Now consider the following quote from Stroustrup and the answer is really a no-brainer:

Without a good library, most interesting tasks are hard to do in 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.

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. 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.

查看更多
小情绪 Triste *
5楼-- · 2020-05-19 05:35

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.

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; i.e., they required a library, other than the 52 libraries that are part of the base system, in order to compile. 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.

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? For any non-trivial use of Boost's facilities the answer is that you should go ahead and use Boost.

查看更多
登录 后发表回答