Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Compiling with individual Boost libraries, Without installing Boost

I'm implementing on some C++ code that I would like to make as portable as possible. I would like to avoid dependencies on libraries that require root access to install. Further, I'd prefer to avoid keeping copies of large libraries in my repository, and I would also prefer not to do user-level installations of libraries (simply because I'd have to manually install them on multiple computers.)

I would like to use the normal_distribution functionality from Boost in my project. I understand that the typical way to install Boost requires a sudo apt-get or sudo yum type of command, but I don't have root access on the systems where this code will run. To get around this, I'm wondering if I could simply place a copy of Boost's normal_distribution.cpp and normal_distribution.hpp in my code directory and compile/link my code with these files. Would this work?

Readers may wonder why I'm not just using the normal_distribution implementation in TR1 or C++11. The answer is that I need to maintain compatibility with some university-managed clusters that still run g++ 4.1.x, which (at least in my experience) doesn't support <TR1/random>.

like image 618
solvingPuzzles Avatar asked Jul 22 '12 00:07

solvingPuzzles


People also ask

Do I need to compile Boost?

Nothing to Build? Most Boost libraries are header-only: they consist entirely of header files containing templates and inline functions, and require no separately-compiled library binaries or special treatment when linking. The only Boost libraries that must be built separately are: Boost.

Is Boost library still useful?

After 20 years of active Boost development, it's now recognized as a very powerful C++ library, for each major version many C++ libraries from the community were added. The Boost reviewers have an advanced C++ skills and their contributions guarantee a high quality for many years.

Can I build Boost with CMake?

One of my current projects relies on Boost. Python, which requires a more recent version of Boost (1.64) than the one (1.54) provided by my Linux distribution (Ubuntu 14.04).

Is Boost still relevant C++?

There are mailing lists devoted to Boost library use and library development, active as of 2022.


2 Answers

I imagine that BCP (Boost Copy) was written precisely with your situation in mind.

like image 50
Kerrek SB Avatar answered Sep 23 '22 14:09

Kerrek SB


You should check out the ryppl project as this is exactly what it is hoping to achieve. If you follow the links to github you will find modularised boost and from there you may go on and try a full ryppl install. In any case there is a half way house and that is modularised boost. There is also a modularised boost/cmake to make it simpler. This is the direction ryppl is looking to take boost and it should be very helpful. The only downside I can see is the propensity to use python scripts for the zero install installer.

As stated BCP was developed for this purpose as well so there is a choice. Be aware though boost is going through a svn->git change and this seems to be affecting some structure which is reflected in some inconsistencies with the current modularised boost, I am not sure how/if that affects BCP as I have no knowledge of that system.

like image 30
dirvine Avatar answered Sep 22 '22 14:09

dirvine