Archive for C++_Boost

Installing C++ Boost on SuSE and Fedora

C++ Boost on SuSE:

its simple to install C++ Boost on a SuSE system by using its YaST package manager.

  1. Run YaST and select "Software" from the left pane. Now select "Software Management" from the right pane and search for "boost" using the Search box.
  2. Select the boost packages that you want to install from the right pane(you atleast need boost – 1.33.0-3) and press the "Accept" button.

You can now test the boost installation by compiling the two programs i had mentioned in my earlier post, using the following commands:

$ g++ -o first first.cpp
$ g++-o second second.cpp -lboost_filesystem

C++ Boost on Fedora:

Installing C++ Boost on RedHat Fedora systems is also along the same lines. first download the boost-1.33.1-5.i386.rpm RPM file from the internet. you can search for a different version of the file if you are not using the fedora core 5 system. install it using the following command(you can directly click on the file):

$ rpm -ivh boost-1.33.1-5.i386.rpm

you can also install it using the yum package manager of Fedora. test the installation just as mentioned in the case of SuSE.

Leave a Comment

Installing C++ Boost on Slackware/Zenwalk

C++ Boost 1.33.1 on Slackware/Zenwalk:

Download bjam slackware package(tgz) and boost-1_33_1 source package(tar.gz) from the website:
bjam for slackware
c++ boost source package

Save these two files in the home directory and then cd into it:

$ cd $HOME

Install bjam(as root):

$ installpkg boost-jam-3.1.11-1-linuxx86.tgz
$ export PATH=$PATH:/boost-jam-3.1.11-1-linuxx86/

Compile and install boost(as root):

$ tar xjvf boost_1_33_1.tar.bz2
$ cd boost_1_33_1
$ bjam "-sTOOLS=gcc" install

C++ Boost is now installed. this procedure doesn't install the files in the default library paths, so compilation commands are slightly longer than they are for gentoo and debian/ubuntu:

$ g++ -o first first.cpp -I/usr/local/include/boost-1_33_1
$ g++ -o second second.cpp -I/usr/local/include/boost-1_33_1 -L/usr/local/lib -lboost_filesystem-gcc

you can simplify this by adding the paths of boost folders to gcc environment variables:

$ export CPLUS_INCLUDE_PATH=/usr/local/include/boost-1_33_1
$ export LIBRARY_PATH=/usr/local/lib

the compilation can now be performed using the following simple commands:

$ g++ -o first first.cpp
$ g++ -o second second.cpp -lboost_filesystem-gcc

the two 'export' commands can be added at the end of the profile file(/etc/profile or $HOME/.bash_profile) to avoid having to type them everytime a new shell is opened. other way to simplify the process would be to create symbolic links to boost library paths in the Slackware standard include paths, so that gcc can find them directly.

Leave a Comment

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:



int main()
boost::any a(5);
a = 7.67;

build this program using:

$ g++ -o first first.cpp

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



namespace bfs=boost::filesystem;
int main()
bfs::path p("second.cpp");

$ 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 (13)

Installing C++ Boost on Gentoo and Debian/Ubuntu

C++ Boost on Gentoo:

on the shell prompt, type:

$ emerge boost

this should install the latest version of boost available for Gentoo. Currently, the latest version of boost, version 1.33.1, is available for Gentoo. synchronise('emerge –sync') with the gentoo portage if your 'emerge -p boost' shows an earlier version.

C++ Boost on Debian/Ubuntu:

$ apt-get install libboost-date-time1.33.0 libboost-doc libboost-filesystem1.33.0 libboost-graph1.33.0 libboost-program-options1.33 libboost-python1.33.0 libboost-regex1.33.0 libboost-signals1.33.0 libboost-test1.33.0 libboost-thread1.22.0

you can use the following simple command to install every library present in boost that matches a pattern, if you don't want to be selective about which libraries to install:

$ apt-get install libboost.*1.33.*

once the boost package is installed, the C++ programs that make use of boost libraries can be built simply like this:

$ g++ -o first first.cpp

if the program needs to be linked to a library(for eg: filesystem library), then specify the name of the library using the -l switch:

$ g++ -o second second.cpp -lboost-filesystem

will follow up with the installation procedure for Slackware and RPM based distributions.

Comments (1)

Setting the Stage for C++ Boost

C++ is a modern language. There is a difference between calling a programming language to be “still applicable” and calling it to be “modern”. “still applicable” languages exist because they are still efficient enough to solve the problems for which they were originally created and that such problems still exist. Modern languages, on the contrary, solve the problems of today, and solve them efficiently. For a language that was created in 1970s, when today’s problems were unimaginable, C++ grew with the time, gone through constant modifications so that it can better reflect the requirements of every age. One excellent proof of the constant improvements that C++ language has undergone to remain competent enough to meet the new challenges, is the C++ Standard Library.

To see the tremendous improvement in the productivity levels obtained by using the higher-level utilities of C++ standard library, consider the following examples: the first one reads a set of names from the standard input, sorts them in the alphabetical order, and then prints them out to the standard output:

vector names;
string name;
while(cin >> name)

sort(names.begin(), names.end());

copy(names.begin(), names.end(), ostream_insterter(cout, “\n”));

Lines 2, 3, and 4 can be further simplified, but i wanted them to be that way. Consider another example, which checks whether a string is a palendrome or not:

compare(pal.begin(), pal.end(), pal.rbegin());

No, there isn’t anything missing out there. That’s all the code that you need to check for a palendrome. Try writing these two samples without using the C++ standard library, and you will see the difference. Its not just a time-consuming effort to write them in C-style of programming, but it also needs more investments in terms of the testing and the maintenance jobs. Still a large number of C++ programmers do not make use of it. But those who do, look at C++ language from a completely different perspective – as a modern and a highly productive software development tool. Like, there hardly would be any memory management chores to do by the programmer, except when creating the low-level libraries.

When one gets used to this style of software development with C++ – making use of its standard library – one starts to wish for more such utilities, that could solve their everyday problems equally effectively. Changes to the C++ language/standard library are not made very frequently in order to provide a level of stability to the technology. The void thus created has been partially addressed by another excellent collection of quality libraries, called C++ Boost Libraries. Its not an official part of C++, but its portable, efficient, rich in functionality and is close enough to the philosphy of standard C++ library. Infact, many of the new additions proposed for the next version of C++ standard library are picked from the Boost libraries. A large number of C++ programmers have already started to make use of these libraries, making it an unofficially official part of the C++ language 😉

Some example libraries present in Boost are: filesystem access library, thread libarary, network socket library, regular expression library, lamba template library etc. There is a large set of collections, algorithms and iterators too. Look at the complete list of libraries if you are interested: there is a list according to the categories of the libraries and an alphabetical list.
I will soon follow this up with a few examples using some of these C++ Boost libraries.

Leave a Comment