Building Gtopo on OS X

Introduction

Gtopo was originally developed under linux, but works just fine under OS X on a Mac computer. I have access only to an intel based MacBook running OS X 10.5 (leopard), so my specific comments will relate to that. I am not a Mac guru, so if your system is different, I won't be much help to you. I have coerced one of my coworkers who has an older power PC based mac to build gtopo, and after I solved some portability issues, it worked just fine for him.

Getting Gtopo

Go to the gtopo downloads page and click on the link to download the latest version. This should deposit a compressed tar file on your system, something with a name like:

gtopo-0.9.13.tar.gz

Now, decide where you want to unpack this tar file. The following command:

tar xzvf gtopo-0.9.13.tar.gz
Will unpack the tar file, creating a directory (within your current directory) with the name gtopo-0.9.13 (or something similar) containing all the source files.

Getting Xcode

You will need the gnu C compiler and the make utility. If you haven't already done so, you will need to go to the Apple Developer website, register (at no cost), and download the latest version of Xcode. This is a 1 gigabyte disk image, and requires nearly 2.7 gigabytes of disk space to install. It includes the gnu C compiler. My version (Xcode 3.1.2) included gcc 4.0.1, and presumably much more.

If you do only this, then try to build gtopo, you will get lots of errors that look something like this:

 make
 cc -c -g gtopo.c -g `pkg-config gtk+-2.0 --cflags`
 /bin/sh: pkg-config: command not found
 gtopo.c:21:21: error: gtk/gtk.h: No such file or directory
 gtopo.c:22:25: error: glib/gstdio.h: No such file or directory
 In file included from gtopo.c:28:
 gtopo.h:109: error: syntax error before 'GdkPixmap'
 gtopo.h:109: warning: no semicolon at end of struct or union
The tipoff here in particular is the message:
gtk/gtk.h: No such file or directory
You need to install some kind of gtk 2.0 development package.

Getting GTK

You have several choices here.

As you may well know, there are two sets of OS X "packages" known as fink and darwinports. Pick one or the other (I picked darwinports).

I found what I thought was a viable option at the gtk+ OS X framework website. This gave me the file Gtk-Framework-2.14-LATEST.dmg, which contains Gtk 2.14. I dutifully installed this, but didn't get a pkg-config, and my makefile didn't work any different than the above, so I call this a complete looser. Without a working pkg-config, this is hardly a viable gtk distribution. Perhaps it integrates itself into Xcode in a way that makes Apple developers happy. Who knows. All I know is that this package did nothing but stink up my machine.

I reinstalled Xcode (since there did not seem to be an uninstall for this thing), hoping that might obliterate any relics this thing left.

Then I installed darwinports (by downloading a dmg for it and letting it run its installer). After that, I was frustrated at first because I could not figure where the just installed port command got installed to (it turns out it went into /opt/local/bin. Then to get gtk, do this:

sudo /opt/local/bin/port -d selfupdate
sudo /opt/local/bin/port install gtk2
The gtk2 step installs one package after the other and compiles them (this takes a really long time). Darwinports pulls in everything but the kitchen sink, even new versions of perl (just to build gtk2!), even a new version of the X server from xorg. Seems excessive, but I just grit my leave and find something else to do while it chugs away. It seems that what darwinports does is to pull pristine sources from the original web sites for each package, apply patches as needed, and then build. Not the way I would do things, but I suppose it has certain virtues. Finally (as of 4-21-2009), it fetches gtk+-2.14.7.tar.bz2 and builds gtk2 from that.

Building

This is simple (once you have installed Xcode and gtk 2 as described above.) Just do this:

cd gtopo-0.9.13
make
On my machine this takes about 10 seconds and yields the gtopo executable. You will probably want to copy it to some directory on your search path. On my machine, I did this:
sudo cp gtopo /opt/local/bin
On my machine, when I start gtopo I get the message:
Xlib: extension "RANDR" missing on display "/tmp/launch-yadayada/:0
I have no idea what this means, but it doesn't seem to stop gtopo from running.

Running gtopo on OsX

The one button mouse means that you loose the "right mouse click to center" feature, any number of keyboard plus mouse shenanigans could be done to replace it, involving the user in ugly finger contortions, but I just do without it. If you are suffering in any severe way because of this, send me email. I am doing more with a MAC these days and may get an idea about how to fix this, I do miss it.

The "two finger drag" that you use to scroll, substitues nicely for a wheel on a mouse on the Mac. The Mac keyboard has a different sort of page up/down keys, that now serve to jog your position on the map the way the arrow keys on a PC keyboard do. If you want some keys (as I do) that serve to change map scales, you have to edit the gtopo config file and assign some keys to this task. I use the u and j keys. I use "u" to replace Page up, and then pick the "j" key because it is below the "u" key on the keyboard. Since this is available to you for fiddling via the config file, you can do whatever you want, as follows:

up_key u
down_key j

Setting up your maps

Follow the instructions on setting up the maps in an archive. There is nothing at all different about doing this on a Mac.
Feedback? Questions? Drop me a line!

Gtopo / [email protected]