Search This Blog

Wednesday, April 7, 2010

Follow up on compiling OMG code

So, I mentioned yesterday that I was gearing up to compile a bunch of C-code that I use but then never really described how to get through the compilation step of the code.  The code I'm referring to is a bundle of programs put together by the Ocean Mapping Group at the University of New Brunswick in Fredericton, Canada.  The group maintains a code repository, to check out a version you'll need to contact someone from the group to get access. This assumes that you've installed Xcode and the extra packages outlined in my post from yesterday. Here it is again, just in case (don't forget to download and install Xcode first):

$ fink install lesstif
$ fink install gsl
$ fink install imagemagick
$ fink install gmt

Step 1 is to get the code repository. You'll need to change "user" to your username given to you by the OMG sys admin folks and machine to the machine they tell you that the repository is stored on.

$ svn checkout svn+ssh://

That'll checkout the repository (name "code") into the directory you're currently sitting in. You can move it anywhere on your file system after you've checked it out.

Step 2 is to set up some environment variables in your shell's configuration files; these direct the code compiling script on where to install things and also update your path with the appropriate directory. I had decided to switch from tcsh to bash since I was already making a transition from PC to Mac, so I had to put together some config files for bash in my home directory. Here's a dump from the .bash_profile file that I cobbled together. You'll need to change username to your username.

export PATH

# For OMG software development
export DEVELOPMENT_HOME=/Users/username
# Sneaky way to shoehorn 32 bit architecture into the makefiles
export CCOMPILER="gcc -m32"
export LOCALLIB=/Users/username/local/lib
export LOCALBIN=/Users/username/local/bin
export LOCALOBJ=/Users/username/local/obj

# For subversion, but only if you're doing commits
export SVN_EDITOR=/usr/bin/vi

Step 3. After that's done, it's time to compile. This uses a mildly flaky script that compiles everything in the appropriate order and then places all the goodies in the locations specified by the environment variables defined earlier. The script is written in tcsh, so you might want to make sure you have that installed (it was on my Mac, but you have to install it on Ubuntu). The script will dump everything in ~/local, again, based on the environment variables set earlier. It will also create an error.log file with a listing of everything it had trouble with.

$ cd ~/code
$ ./compile_every_gd_thing

That should do it!

1 comment:

  1. A fun starter way to look at a Makefile...

    fink install sioseis
    tar xf /sw/src/sioseis*.tar.bz2
    cd sioseis*
    less makefile

    Would be better with all those CFLAGS uncommented...