About Me

My photo
A Computer Enthusiast who's learning as much as I can, while attempting to share and re-distribute the knowledge! Enjoy! :D

Monday, July 12, 2010

Boost Libraries and Eclipse

Installing Boost Libraries

1. Download the most recent version of Boost Libraries - http://sourceforge.net/projects/boost/files/boost/

2. Within the directory where you want to put the Boost Installation, execute the following:
  • tar --bzip2 -xf /path/to/boost_1_45_0.tar.bz2
Lagatuz-MacBookPro:Downloads marklagatuz$ pwd
/Users/marklagatuz/Downloads
Lagatuz-MacBookPro:Downloads marklagatuz$ tar --bzip2 -xf boost_1_45_0.tar.bz2

You now have a working Boost Library consisting of Header files. If you would like to make sure of the compiled libraries ... continue on!

3. Set up the Boost Compiled Library
  • Run the bootstrap strict with the --help option to receive options
./bootstrap.sh --help
  • Create the directory where you would like the Boost Library Binaries to reside
Lagatuz-MacBookPro:Downloads marklagatuz$ pwd
/Users/marklagatuz/Downloads
Lagatuz-MacBookPro:Downloads marklagatuz$ mkdir boost_1_45_0_Compiled
  • Change directory into the boost installation directory (header files only)
Lagatuz-MacBookPro:Downloads marklagatuz$ cd boost_1_45_0
Lagatuz-MacBookPro:boost_1_45_0 marklagatuz$ pwd
/Users/marklagatuz/Downloads/boost_1_45_0
  • Run the bootstrap script. I've added the following options:
  • --prefix: is for my own installation directory choosing.
  • --with-libraries. is for choosing which library binaries I want installed

Lagatuz-MacBookPro:boost_1_45_0 marklagatuz$ ./bootstrap.sh --prefix=/Users/marklagatuz/Downloads/boost_1_45_0_Compiled --with-libraries=all
  • Finally, install the binaries (a /lib will be created inside the prefix directory)
Lagatuz-MacBookPro:boost_1_45_0 marklagatuz$ ./bjam install

Congratulations ... you have the Boost Libraries installed!

Integrating Boost with Eclipse

After a successful installation of Boost Libraries on your system, here are some steps to integrate the Library with Eclipse. I've installed on OS X, so a Linux flavor should be similar.

If you want to utilize the Library which are only inline and templates (non-compiled):

1. Within Eclipse: Go to Properties menu
  • Project --> Properties
2. Add the headers into your Include path during compilation
  • C/C++ Build --> Settings --> GCC C++ Compiler --> Directories
  • Add the location of your installed Boost Library Include Path (/Users/marklagatuz/Downloads/boost_1_43_0 for me)
3. Finally save the configuration

If you want to utilize the Library which are compiled:

1. Within Eclipse: Go to Properties menu
  • Project --> Properties
2. Add the headers into your Include path during compilation
  • C/C++ Build --> Settings --> GCC C++ Compiler --> Directories
  • Add the location of compiled Boost Library Include Path (/Users/marklagatuz/Downloads/boost_compiled/include for me)
3. Add the compiled Library to the Library search path during linking
  • C/C++ Build --> Settings --> GCC C++ Linker --> Libraries --> Library search path (-L)
  • Add the location of the compiled Boost Library (/Users/marklagatuz/Downloads/boost_compiled/lib for me)
4. Add the specific Library name to the Libraries
  • C/C++ Build --> Settings --> GCC C++ Linker --> Libraries --> Libraries (-l)
  • Add compiled Library name you would like to utilize
5. Finally save the configuration

You are ready to utilize the Boost Library during your development!

--
Resources

1. Boost Getting Started Guide
  • http://www.boost.org/doc/libs/1_45_0/more/getting_started/index.html