Archive for March 16, 2006

How to test C++ Boost installation

once boost is installed on a machine, the fastest way to test the installation is to use some of the libraries from it in test C++ programs, and then try to build them. the following two programs can be used for this purpose:

first.cpp

#include<iostream>
#include<boost/any.hpp>

int main()
{
boost::any a(5);
a = 7.67;
std::cout<<boost::any_cast<double>(a)<<std::endl;
}

build this program using:

$ g++ -o first first.cpp

the second example needs to be linked to a library file.

second.cpp

#include<iostream>
#include<boost/filesystem/operations.hpp>

namespace bfs=boost::filesystem;
int main()
{
bfs::path p("second.cpp");
if(bfs::exists(p))
std::cout<<p.leaf()<<std::endl;
}

$ g++ -o second second.cpp -lfile_system

if the above two programs build and run with out any problems, then boost is installed and working properly on your system.

Comments (5)