How to Test C++ Boost Installation
Once C++ 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 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:
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;
-
}
If the above two programs build and run with out any problems, then boost is installed and working properly on your system.
Related Posts:
Readers who viewed this page, also viewed:
- Installing C++ Boost on Microsoft Windows for Visual Studio .NET 2003/2005/Orcas
- Installing C++ Boost on Gentoo and Debian/Ubuntu
- C++ Boost Filesystem Library(Part II): Example Programs
- C++ Boost Filesystem Library(Part III): Example Programs
- Six Popular IDEs For Developing Software in C/C++ on Windows Platform
[...] You can now test the boost installation by compiling the two programs I had mentioned in my earlier post, using the following commands: [...]
QuotePingback by Every Flavour Beans » Installing C++ Boost on SuSE and Fedora — April 28, 2006 @ 2:47 am
Thanks - the article was very helpful!
(I think comment #1 may have gotten "eaten" - perhaps it referred to the examples folders and Jamfile included with the distribution?)
Please keep up the good work!
QuoteComment by JOanzi — December 6, 2006 @ 7:44 am
JOanzi,
Thanks.
The comment #1 is actually a pingback/trackback and is displayed only partially. The full text can be read by following the URL at the bottom("Pinkback by ...").
QuoteComment by tabrez — December 6, 2006 @ 2:55 pm