Archive for March, 2006

Java on Gentoo

The simplest way to get started with Java development in Gentoo is to install the Blackdown JDK-1.4.2 along with the Eclipse IDE:

$ emerge blackdown-jdk eclipse-sdk

if you want to install the sun's version of the jdk, instead of blackdown jdk, you can get the 1.4.2 version of it using:

$ emerge sun-jdk java-sdk-docs

to install the 1.5 version of the jdk, you need to unmask it first. add the following two lines to your /etc/portage/package.keywords file:

>=dev-java/sun-jdk-1.5.0 ~x86
>=dev-java/java-sdk-docs-1.5.0 ~x86

now do the emerge:

$ emerge sun-jdk java-sdk-docs

you can also install both of these versions at the same time, and then make one of them as the default jdk. if you need java support in other applications too(like web browser etc), then make sure to add the relevant keywords in the /etc/portage/package.use file:

=dev-java/sun-jdk- X alsa browserplugin doc examples jce mozilla nsplugin

this also installs the documentation and the examples. change the version number if you are installing the 1.5 version of the jdk.

if you want to use Eclipse IDE to create C++ programs, you need the eclipse-cdt package. first unmask it by placing the following line in /etc/portage/package.keywords file:

>=dev-util/eclipse-cdt-2.0 ~x86

now do the emerge:

$ emerge eclipse-cdt

here is more information on installing java 1.5 and eclipse 3.x on Gentoo OS.


Comments (3)

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

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)