views:

139

answers:

4

I work on a cross-platform (Windows, Linux, Solaris) project. I want to use Boost's shared_ptr in this project.

How can I install it, and redistribute it with the project to the customers?

I don't have root permissions on Linux/Solaris, so I probably have to add Boost' sources to my sources, and build it together.

Also, our version of Solaris is very old (2.5.1, May 1996). Can it cause any problem with the building of shared_ptr?

+3  A: 

There's no need to include sources of the Boost library (Boost is a pretty big library). Just include Boost in your prerequisites.

In case if you redistribute your project in binary form you don't need to include Boost libraries at all.

Kirill V. Lyadvinsky
+3  A: 

boost::shared_ptr is header-only. Just add the necessary header file(s) to your project and you are done.

shared_ptr is also part of TR1, the first C++ Library Technical Report and is e.g. included in newer versions of GCC (>= 4.0.0) (see here for further information).

Greg S
Note that `shared_ptr.hpp` depends on some other header files.
Kirill V. Lyadvinsky
Boost comes with a program called `bcp` that takes care of that. It will look through your source to find the boost header files that you use, and recursively go through them to build a minimum set. We do this automatically in our build scripts, and it works well.
KeithB
+2  A: 

Just install the boost header files (you don't need to compile and install the libraries for shared_ptr, because it's header only). Don't forget to check if the include paths for boost are set up right inside your IDE, so it will be able to find the header file.

In your code file, include this header:

#include<boost/shared_ptr.hpp>

and use it like this:

boost::shared_ptr<int> ptrToInt (new int);
toefel
+1  A: 

You don't need much of the boost library just to use shared_ptr. Use the bcp tool to extract just the bits that shared_ptr depends on, which may be preferable to installing the full library.

the_mandrill