Raspberry Pi – Install boost 1.50 C++ Libraries on Wheezy

If you are doing modern C++ development these days you will be using the boost libraries. I have started using the Raspberry Pi as a stand-in ARM platform for some smart-cam development while I wait for the actual hardware to become available and as such need to install boost. To this end, the boost 1.50 libs can be installed on wheezy as follows:
[crayon lang=”Shell”]
sudo apt-get install libboost1.50-all
[/crayon]
Now for a little example of using and building with the libs, consider this little test program that uses the boost regex library:

[crayon lang=”cpp”]

#include
#include
#include

int main() {

std::string text(“a fat cat sat on the mat”);
boost::regex re(“\\w+”);

boost::sregex_token_iterator i(text.begin(), text.end(), re, 0);
boost::sregex_token_iterator end;

for( ; i != end ; ++i ) {
std::cout << *i << ' '; } std::cout << std::endl; return 0; } [/crayon] If we stick this code into a file called it.cpp then we can build it using C++0x (C++11 ish), the standard c++ lib and the boost regex lib like this:

 

[crayon lang=”Shell”]
g++ -std=c++0x -lstdc++ -lboost_regex it.cpp
[/crayon]
This will output to a.out, which can then be executed like this:

./a.out
 
1 reply

Comments are closed.