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:
1 | sudo apt-get install libboost1.50-all |
Now for a little example of using and building with the libs, consider this little test program that uses the boost regex library:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | #include <iostream> #include <string> #include <boost/regex.hpp> 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; } |
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:
1 | g++ -std=c++0x -lstdc++ -lboost_regex it.cpp |
This will output to a.out, which can then be executed like this:
1 | ./a.out |
nice example merci !