Compiling - Linux

Instructions aimed at Debian/Ubuntu & Fedora/CentOS, but could easily be adjusted to fit other Linuxes, BSD's and Solaris.


1. Get required programs


Debian / Ubuntu

sudo apt-get install libgtk2.0-dev gettext git-core cmake gpsd gpsd-clients  libgps-dev build-essential wx-common libwxgtk2.8-dev  libglu1-mesa-dev libgtk2.0-dev wx2.8-headers libbz2-dev libtinyxml-dev libsdl1.2debian

Fedora / CentOS

yum install git cmake rpm-build gcc-c++ libstdc++-devel gtk2-devel wxGTK-devel mesa-libGLU-devel mesa-libGL-devel gettext bzip2-devel

OpenSuSE

zypper install git cmake gcc-c++ libstdc++-devel gtk2-devel wxWidgets-wxcontainer-devel MesaGLw-devel gettext-runtime gettext-tools libbz2-devel gpsd-devel libgps19-devel 

Cmake must be a version > 2.8, which means Ubuntu 10.4 or later (9.10 with backport repository enabled), or Fedora 13 or later.
Important Cmake Note: Due to a bug in Cmake, the "pixbuf-bug", it is recommended to upgrade to Cmake version >= 2.8.3.
Fedora 14 is updated, while on Ubuntu 10.10, it is necessary to enable the backport repository.Tick Synaptic->Settings->Repositories->Updates>Unsupported updates(maverick-backports).

Note that these packages will install a significant number of other dependencies as well...

Optional: Remove old installation
Only required if opencpn .deb / .rpm was installed previously

Debian / Ubuntu

sudo apt-get remove opencpn

Fedora / CentOS

yum remove opencpn

OpenSUSE

zypper remove opencpn
 
 

2. Download source code. 


Run this to get your local copy of the source code:
git clone git://opencpn.git.sourceforge.net/gitroot/opencpn/opencpn

To update an existing local copy, issue the following commands:

cd opencpn
git pull
 

3. Build it.


We'll build everything in a subdirectory to keep the codebase clean (easier to catch changes).
cd opencpn   # unless already in this directory.
mkdir build
cd build
cmake ../
make

Notes:

Default install in /usr/local, you can change this by providing cmake appropriate option:
cmake -DPREFIX=/usr ../

If you're not into debugging, change to this to generate a smaller and marginally faster binary:
cmake -DCFLAGS="-O2 -march=native" ../

cmake is only required if you build source code for the first time, then running make is enough, even if you updated the source code.

**Ubuntu 10.10 fails to build...
Change the path in this line in CMakeCache.txt:  GTK2_GTK_INCLUDE_DIR:PATH=/usr/include/gtk-2.0
 

5. Install it or create a package

 
sudo make install

OR you could do this, to make  your own .deb & .rpm packages (require cmake > 2.8.2):
In the build directory issue
sudo make package

To make a 64 bit package, don't forget to use -DARCH as described above.

6. Others

1. Script to make the Git/Cmake process easy.

  ---
#! /bin/sh
#Change this line to where you want the OpenCPN source on your computer.
cd /home/thomas/Testing/GitOpenCPN
GIT=0
test -d opencpn
if test $? -eq 1
  then 
    git clone git://opencpn.git.sourceforge.net/gitroot/opencpn/opencpn
    GIT=1
fi
cd opencpn
if test $GIT -eq 0
  then
    git pull
fi
test -d build
if test $? -eq 1
  then
    mkdir build
fi
cd build
rm -f CMakeCache.txt
cmake  ../
make
echo "Cmake OK!"
sudo make install
exit
---

2. Compiling older releases.

Old way from CVS, no longer maintained

cvs -z3 -d:pserver:anonymous@opencpn.cvs.sourceforge.net:/cvsroot/opencpn co -P opencpn  

Earlier releases used the gnu automake toolchain, with the following basic commands:

aclocal
automake --add-missing
autoconf
./configure
make

make install