How to Compile XEphem on Ubuntu Linux

Following is a (hopefully) painless guide to compiling the excellent astronomy program named XEphem (http://www.clearskyinstitute.com/xephem/) on the Ubuntu linux distribution. Though we now have Stellarium and KStars, XEphem has some unique features and the source code is free for personal/educational use (check the URL for precise terms). In addition, it doesn't require a higher-end OpenGL graphics card. It'll run well on a fairly modest machine. I've tested these steps on Ubuntu 8.04 Hardy Heron and they worked for me without any trouble.

(1) Preliminaries & Packages.

Use either "sudo apt-get install" or Synaptic to pull down (or verify that you already have) the following packages installed:

gcc
lesstif2-dev
libc6-dev
libxmu-dev
make

Since I embarked on this document (perhaps in 2005), I've noticed a couple changes with the Ubuntu packages. When you install the gcc compiler it sets up a symlink automatically from /usr/bin/gcc to the /usr/bin/gcc-{version number} executable. In the past, you may have needed to create this symlink yourself. For the newbies: 'cd /usr/bin', then 'ln -s gcc-4.0 gcc' or whatever was the gcc version.

If you'd rather compile with libmotif3 and libmotif3-dev (instead of the lesstif2 and lesstif2-dev respectively), you'll need to go into Synaptic (or edit /etc/apt/source.list manually), enable the Non-free Multiverse repository, and install those packages instead. There are some licensing politics surrounding motif.

In any case, I've successfully compiled XEphem 3.7.3 with gcc-4.x and the LGPL lesstif2/lesstif2-dev Ubuntu maintained packages, as well as the libmotif3/libmotif3-dev alternative.

(2) Get the XEphem source code.

Go here: http://www.clearskyinstitute.com/xephem/. Download it to a directory, for instance your user directory, and ungzip/untar it. It'll be in a directory named "xephem-3.7.3" (depending on version number).

(3) Make a change to the xephem-3.7.3/libz/Makefile

This file may initially be read-only, so be sure to chmod +w it if necessary. I noticed this issue with the source for XEphem 3.7.1 and 3.7.2 as well. There's a couple things missing from the makefile in the xephem-3.7.3/libz/Makefile file. Make sure the top of that file includes this:

CC = gcc
CLDFLAGS = -g
CFLAGS = $(CLDFLAGS) -Wall -O2
LDFLAGS =

And the bottom of the file needs to have "gcc" specified rather than cc.:

testzlib: testzlib.o libz.a
gcc $(LDFLAGS) -o testzlib testzlib.o libz.a

(4) Compile XEphem.

This part depends on your version of Ubuntu. I've found that Hoary Hedgehog 5.04 put the motif libraries in /usr/X11R6/lib, and Dapper Drake places them in simply /usr/lib. Whether you're using motif or lesstif, the XEphem makefiles expect some value for "MOTIF=" in order to compile. I'm unsure about Breezy Badger (it'll be one or the other). Go to the xephem-3.7.3/GUI/xephem directory.

If running Ubuntu 5.04 issue this:
make MOTIF=/usr/X11R6/lib/

If running Ubuntu 6.06+ issue this:

make MOTIF=/usr/lib/

XEphem should now successfully compile after a minute or so, depending on the speed of your hardware.

(5) Run and test.

Go to /xephem-3.7.3/GUI/xephem and type "./xephem" to execute. The first things you might want to do is to set the observer location to your own and confirm that your time/zone information is correctly indicated.

I like to create a KDE desktop icon for XEphem. From the KDE desktop, right-click and create a new link to an application. Go to the directory /xephem-3.7.3/GUI/xephem and select the xephem executable, change the icon to the XEphem.png file there. Then make sure the working directory is set to /xephem-3.7.3/GUI/xephem (or wherever you actually installed it).

Enjoy!


The views and opinions expressed in this page are strictly those of the page author.
The contents of this page have not been reviewed or approved by the University of Minnesota.