Getting on a Decent Version of Boost
Wednesday, June 30th, 2010In the past, I've gone the "roll your own" mode with C++ libraries, and there's a lot to like about the model. First, if it's in the C++ compiler (GCC), then it's free, automatic, and you use it - unless there's a compelling reason not to. Second, if there's an RPM for the system, use that as it's easy to place on every box and it's close to being in the compiler as it's been installed in the obvious locations for the compiler to pick up. Third, if you need to compile it from source, then do that, but it means that you either have to make a tarball to place it in /usr/local, or you have to manually install it on all the boxes, or you have to place it in the delivery package with your code. Finally, you can write your own.
But there are a lot of reasons to skip to the last step. I can remember doing performance tests on the STL vector - not impressive in speed. So I write a vector template class that's a ton faster because it's a simple array of instances. It's not as generic as the STL version, but for all the things I needed, it was far better. So there are reasons, sometimes.
But in this new rewrite I'm doing at The Shop, I decided to try to use as much Boost as possible. There are a ton of libraries in Boost. It's going to be in the next C++ standard, and that means it's going to be in GCC, so there's plenty of reasons to use it. I looked, and for CentOS 5, there are RPMs for Boost! What a break. Problem is, they are for version 1.33.1, which is several years old, and missing some very key features for me.
Further complicating the problem was how to approach the inclusion of Boost, should I choose to upgrade to the latest version for this project. What I wanted was an RPM of the i386 and x86_64 versions of the libraries and the headers. It's certainly possible to make one from the source, but that's a ton of work that just doesn't seem to be worth the effort. While it might be nice to build it and make it available to the world, as an option for folks in my shoes, it seems that having no experience in making an RPM puts me in the distinct disadvantage here.
Putting it in /usr/local means that there's something I need to put onto each machine, and if it's got the RPMs installed already, there's a real possibility that there could be some serious conflicts. Additionally, The Shop doesn't have a nice NFS mount point for all this open source code where it's organized by the project, the version, etc. and therefore available on all machines naturally.
I'm left with the icky realization that the easiest and safest method is to package it with the app. I really hate this, but there's really no other solid alternative.
So how do I get the latest Boost?
It's really a lot simpler than the Boost web site describes:
cd /usr/local/src wget http://sourceforge.net/projects/boost/files/boost/1.43.0/boost_1_43_0.tar.gz tar zxvf boost_1_43_0.tar.gz cd boost_1_43_0 ./bootstrap.sh ./bjam sudo ./bjam install
That's it. Now this will install it into /usr/local by default, and I didn't do that last step, but had I beed doing this on machines I really controlled, I probably would have. I just think putting a library with the project is just wasteful. Too many people might want to use it, and that's the point: Get a recent version on the box and use it.
I'm still toying with the idea of building an RPM, but I need to get this project going and then hassle with the libraries. The only difference would be in the Makefiles and the deployment strategy, and those can wait for now. It's built, it works, and I can write code.
Good enough.
I sure do wish they'd make the RPMs for a reasonably recent version available on a web site, though. That would be really nice.