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://user@machine.omg.unb.ca/drives/machine/disk1/code


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.


PATH=$PATH:/Users/username/local/bin
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!

Tuesday, April 6, 2010

Getting my Mac on

I started my new job on Friday and I had come face to face with what seemed like a good idea one month earlier:  I was going to switch my digital life from a PC to a Mac.  Backstory: I've been living off of a 5 year old Dell Latitude that was dual-booting Windows XP (used only for MS Office) and Xubuntu (9.10) and was sick and tired of rebooting into windows just to have a clean look at Powerpoint and Word files.  I'm a command line kind of guy so I figured I could do all of that on a Mac without the Windows hassle.  That was the logic behind the move, only time will tell whether it was the right decision.  I'm using this blog to document everything I've done during the transition so that I might someday remember all of this if I have to move to another Mac.  Maybe it might even be useful to another Mac newbie.

As a few days have passed already, I'm just jotting down stuff from memory.  First order of business was to make sure I could compile all the C-code I've been working with over the years.  After talking to some co-workers, I found out I need to install this stuff:
  • Xcode: this puts all sorts of development goodies at my fingertips, e.g. gcc, X headers for Linuxy graphics programs I use.  After signing up to be an official Apple Developer (Mom would be so proud), I downloaded an archived .dmg file which installed simply by dragging it onto my Application folder.
  • fink: this lets me get lots of open source code that I use for some of my software development and scripts that I use in my research.  Stuff I really needed to get going was the GNU Scientific Libraries, GMT, ImageMagick, lesstif and a few others I can't remember off the top of my head.  Fink downloaded as a tarball and was pretty painless to install.  It asked an awful lot of questions and I just went with the defaults but found out afterwards that I should have probably chosen the "unstable" branch but it's worked well for me so far.
I googled my way through importing my email from Thunderbird on my PC to the Mac.  Most folks suggested just copying over your "profile" folder and updating profile.ini with your old profile name.  It worked for me without any difficulties.  Probably should have made sure I had the same version of Thunderbird running on the PC and the Mac but didn't think of this until I was halfway through.

That's it for now...