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 sourceforge.net 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.

Advertisements

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:

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 (14)

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)
names.push_back(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

C# on Gentoo

.NET developers looking for a similar development framework on gnu/linux operating system should check out the Mono project. its fairly simple to install Mono on most of the gnu/linux environments and start developing applications using the C# language. but beginner programmers would love to have an easy to use IDE which could integrate all the tools required for C# based development in one place. one such tool is MonoDevelop which is fast developing into a useful product. installing it on rpm based distribution was not a satisfactory experience for me however. but i knew it should be easy to install it on Ubuntu and Gentoo operating systems. if you have included Mutliverse and Universe repositories in the apt source list, then MonoDevelop is just one 'apt-get install' away on Ubuntu. it required only a bit more effort on a Gentoo system, so i am documenting it here.

Most of the packages required to get MonoDevelop working on a Gentoo system are in the masked state. put the following lines in the /etc/portage/package.keywords file(create it if it already doesn't exist):

>=dev-dotnet/gtkhtml-sharp-2.4.0 ~x86
>=dev-dotnet/glade-sharp-2.4.0 ~x86
>=dev-dotnet/gconf-sharp-2.4.0 ~x86
>=dev-dotnet/art-sharp-2.4.0 ~x86
>=dev-dotnet/gnome-sharp-2.4.0 ~x86
>=dev-dotnet/vte-sharp-2.4.0 ~x86
>=dev-dotnet/gnomevfs-sharp-2.4.0 ~x86
dev-dotnet/gtksourceview-sharp ~x86
dev-dotnet/gecko-sharp ~x86
dev-dotnet/libgdiplus ~x86
dev-util/monodevelop ~x86
dev-lang/mono ~x86

you can drop ">=" in front of some of the lines above by dropping the version numbers in the same lines.
eg: dev-dotnet/gtkhtml-sharp ~x86
now run 'emerge monodevelop' to get everything installed:
#emerge monodevelop
'emerge mono' will get only the mono environment and all development can be carried out using your favourite editor and command shell.

if you get any problems, first try 'emerge sync' to get everything synchronised, and then rerun 'emerge monodevelop'. if you still get any errors, see if still there are any dependency problems left that are in the masked state. if so, add them too to the '/etc/portage/package.keywords' file and repeat the process.
let me know how this works out for you, as i haven't found much information regarding this on the internet.

Comments (5)

K3B and amaroK: Only KDE applications I use

Whatever Linus Torvalds might have to say, i am happy with the GNOME desktop manager. i have used KDE for far too long, before i switched to GNOME, and i had never liked KDE very much – for whatever reasons. i liked a lot of applications in KDE though, like KDevelop, Kate etc. but i could always install and use these applications from GNOME too, albiet they might load a little bit slowly in GNOME. the number of KDE applications that i would use in GNOME started to decrease everyday, and very quickly i found that i was not using a single KDE application any more. that is the reason why i never felt any discomfort while using the Ubuntu operating system, which is completely a GNOME based distribution(the kde version of it is called Kubuntu). but the situation did not last for too long…and i came to know about atleast two killer KDE applications, which have compelling enuogh features to make them must-haves even for a GNOME user: K3B and amaroK. whereas GnomeBaker has a simple interface, K3B makes it extremely easy to do a lot of operations, like making a cd-to-cd copy, multisession burning etc, that are difficult to do in other cd burning apps, or are not yet supported. K3B is a combination of ease of use and a great feature set. when it comes to amaroK, it simply rocks! its interface allows so much to be done and yet it is so simple to use. it allows searching and saving album covers over the internet, has features for digging up song lyrics and for looking up artists in Wikipedia. it can transform to a smaller window while it is playing aka xmms or can just play from the notification area. got good skins and presets too. so even if you are a GNOME user, you definitely need atleast these two applications from the KDE stable.

Comments (2)

Another system rescue story, using Ubuntu LiveCD

Adding to what i had written in one of my earlier posts about the rescue act using a gnu/linux live cd , here is a related story posted on the ubuntu-users mailing list:
(this is a trimmed version, full story here)

A horror story with a potentially happy ending.

So, I use PartitionMagic 8.0 to move a few things around for the
ever-expanding Ubuntu portion of my hard disk. Then the god-awful happens: in the middle of applying my changes, Partition magic gives one of its ever-helpful error messages (“Error #705 applying changes.”) and stops.
[…]
Now since I am primarily a Windows user (and all my software and work sits under Windows as a result), my natural reflex was to pull out my Windows recovery disk to see what I could do. What a damned joke. Apparently, to Sony, “recovery” means “erase everything on the whole disk and put back in the vanilla install”. There was no option of any kind to try and restore the MBR or any such thing. Just a snide “it is advised to back up your critical data before proceeding”-style message. Bastards!

Luckily I have Ubuntu. And, more specifically, I have my Ubuntu LiveCD. Which I booted and fired up GParted in. To see that I have…. nopartitions. Time to go hunting.

Having a fully-functional system despite not having a functional hard drive has its advantages. Sure it may be slow as all Hell on a CD, but it works. And it lets me surf the net to find possible solutions before giving up and losing literally years of data. Ordinarily I’d have to go to another computer (say in my classroom) to research solutions and download things and even mess with the hard drive (after removing it), but the Ubuntu LiveCD rendered that unnecessary. On the same crippled machine I could do whatever I needed to do.
[…]
So here’s where things stand now. GRUB is saved. Ubuntu works (with a few annoying glitches — I may just reinstall the system and restore my /home, taking the opportunity afforded to modify my partitioning scheme […]
‘ll do Sony’s version of “recovery”, restore my vital data (which is sitting on that handy external disk — the partition can’t be booted, but it reads just fine!), and then uninstall everything under Windows but for the few applications left which don’t have a suitable Linux alternative. (That list shrinks regularly and consists now of mostly games.) I’ll wind up with 5-10GB devoted to Windows and 30GB devoted to Linux. And Linux — Ubuntu — will be the OS I use most of the time now.
[…]

Ubuntu Live CD can be downloaded here.
You can also get it shipped to anywhere around the world, free of cost, from here.

Leave a Comment

« Newer Posts · Older Posts »