Wednesday, February 2, 2011

TOS: Freeciv Exercise

For this assignment, we were supposed to go through the Freeciv example in chapter 5 of the TOS textbook. The purpose of this exercise was to learn about building source code. We've all done this before, but it was nice to follow the steps and get a better understanding for the process.

Using svn to get the code was simple. Installing the first half of the dependency packages seemed simple. Then I reached the Glib dependency. The author was able to get the package easily but no matter how I tried to get Glib on my machine, it couldn't find it. So I did what the author suggested and Googled it. I just typed 'how to install glib on ubuntu'. I found a forum where someone else was trying to glib and another user posted that they needed to type 'sudo apt-get install build-essential libglib2.0-dev', and this worked! Easy enough.

For the next three dependencies the author combined them all into one line, 'yum install atk pango gtk+'. (Which reminds me, since I am in Ubuntu, I don't use the commands he used. I had to use apt-get to install packages and dpkg -s to look to see if I had packages installed already instead of rpm -q). So, when I entered 'sudo apt-get install atk pango gtk+' the terminal responded with 'couldn't find package atk'. I figured I would turn to Google for information on how to install atk on Ubuntu but it wasn't easy to find information about this package. I turned to the install file that I opened at the beginning of this exercise. It says to get the package from ftp://ftp.gtk.org/pub/gtk/v2.6/atk-1.9.0.tar.bz2. So I downloaded the tar file, extracted it, ran ./configure, make, and make install. Everything went smoothly until make install. For some reason at this part I received a "cannot create regular file" error, and a "permission denied" error. I entered dpkg -s atk and it said that atk was not installed. I opened the Ubuntu Software Center and searched for Atk and this stated that libatk1.0-0, the ATK accessibility toolkit was installed. I wasn't sure if I need libatk1.0-0 or libatk1.0-dev. And this appeared to be the case for pango and gtk+.

I decided to just keep going to see if I get an error saying that they aren't installed, then I would come back and try again. But I didn't. Following along with the example, I received a different error than the author. My C++ compiler was fine; I received an error about libcurl development files. The example didn't get this error, so I was on my own to try to get this one. In the Ubuntu Software Center, there were two entries for 'development files and documentation for libcurl', GnuTLS and OpenSSL. I decided to just install the first one to see if it would be sufficient and it was. However, I still received yet another error. But this error was also received by the author in the exercise.

I didn't like how I couldn't find gtk+, gtk+2, or gtk2! So again I had to just try to Google information about it. Thank goodness for all of these forums, they can be so helpful. I found a forum where these two users were going back and forth trying to get gtk2 to install. They eventually got to this command 'sudo apt-get install gnome-core-devel build-essential libgtk2.0-dev libgtk2.0-doc dev-help'. I didn't need to enter build-essential because I had already done this, and I didn't type dev-help because the user showed that s/he received an error that dev-help could not be found. And it appeared that the command worked! This seemed to be more work than what the author had to go through but I also didn't get the next error that he received about gtk2-devel. Although, I did feel like he did when I saw 'Now type 'make' to compile freeciv'!!

The next step was to enter make. The author wanted to use the Unix trick to send output and error messages to files. The funny thing is, we just learned about this Unix command today in Operating Systems. At first I was afraid to do this, I might mess something up. But I decided to try it. I waited and hit enter after a while. I didn't see anything. Oh no... maybe I just have to wait a while longer.. he did say go get a cup of coffee and engage in some serious business somewhere else. Ah, it's done now.

Following this example made the build process seem kind of easy. Don't get me wrong, I thoroughly enjoyed being able to successfully build and compile the code! But I don't think it would have went through so smoothly if I was just following the install file. In the install file, it listed where to get the tar files. Once you download those, you have to run ./configure, make, and make install. However, by following the author, I just had to run sudo apt-get install for the packages. Overall though, I felt like it was a very useful experience. I believe I learned a lot and can understand the process a little better now.

No comments:

Post a Comment