Every Flavour Beans

“The time has come…to talk of many [technologies].” –Lewis Carroll(’The Walrus and the Carpenter’)
Development Tools. Web Frameworks. GNU/Linux. Nokia N800. Video Encoding.

March 16, 2006

How to Test C++ Boost Installation

Filed under: C++ Boost — tabrez @ 4:02 pm

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

C++:
  1. #include<iostream>
  2. #include<boost/any.hpp>
  3. int main()
  4. {
  5.     boost::any a(5);
  6.     a = 7.67;
  7.     std::cout<<boost::any_cast<double>(a)<<std::endl;
  8. }

Build this program using:

sh# g++ -o first first.cpp

The second example needs to be linked to a library file.
second.cpp

C++:
  1. #include<iostream>
  2. #include<boost/filesystem/operations.hpp>
  3. namespace bfs=boost::filesystem;
  4. int main()
  5. {
  6.     bfs::path p("second.cpp");
  7.     if(bfs::exists(p))
  8.     std::cout<<p.leaf()<<std::endl;
  9. }

sh# g++ -o second second.cpp -lboost_filesystem

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


If you want to receive future posts by email, enter your email address here:

Related Posts:

  • Installing C++ Boost on SuSE and Fedora
  • Installing C++ Boost on Gentoo and Debian/Ubuntu
  • Installing C++ Boost 1.34.1 on Slackware/Zenwalk
  • C++ Boost Filesystem Library(Part III): Example Programs
  • Installing C++ Boost on Slackware/Zenwalk
  • Installing C++ Boost on Microsoft Windows for Visual Studio .NET 2003/2005/Orcas
  • C++ Boost Filesystem Library(Part II): Example Programs

  • Readers who viewed this page, also viewed:


    3 Comments »

    1. [...] You can now test the boost installation by compiling the two programs I had mentioned in my earlier post, using the following commands: [...]

      Quote

      Pingback by Every Flavour Beans » Installing C++ Boost on SuSE and Fedora — April 28, 2006 @ 2:47 am

    2. 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!

      Quote

      Comment by JOanzi — December 6, 2006 @ 7:44 am

    3. 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 ...").

      Quote

      Comment by tabrez — December 6, 2006 @ 2:55 pm

    RSS feed for comments on this post. TrackBack URI

    Leave a comment

    Subscribe without commenting


    Copyright (c) 2006, 2007 Tabrez Iqbal.
    Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2 or any later version published by the Free Software Foundation; with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts. Verbatim copying and distribution of this entire article is permitted in any medium without royalty provided this notice is preserved. A copy of the license is included in the section entitled "GNU Free Documentation License".


    Powered by WordPress
    This website is hosted by Dreamhost