All pastes #576692 Raw Edit

Someone

public text v1 · immutable
·published 2007-06-19 16:08 UTC
rendered paste body
4. Building on GNU/Linux
  ========================


	4.1. Building QGIS with Qt4.x
	=============================

*Requires:* Ubuntu Edgy

These notes are for if you want to build QGIS from source. One of the major
aims here is to show how this can be done using binary packages for *all*
dependencies - building only the core QGIS stuff from source. I prefer this
approach because it means we can leave the business of managing system packages
to apt and only concern ourselves with coding QGIS! 

This document assumes you have made a fresh install and have a 'clean' system.
These instructions should work fine if this is a system that has already been
in use for a while, you may need to just skip those steps which are irrelevant
to you.


	4.2. Prepare apt
	================

The packages qgis depends on to build are available in the "universe" component
of Ubuntu. This is not activated by default, so you need to activate it:

1. Edit your /etc/apt/sources.list file.  
2. Uncomment the all the lines starting with "deb"

Also you will need to be running (K)Ubuntu 'edgy' or higher in order for 
all dependencies to be met.

Now update your local sources database:


  sudo apt-get update 



	4.3. Install Qt4
	================


  sudo apt-get install libqt4-core libqt4-debug libqt4-debug-dev \
  libqt4-dev libqt4-gui libqt4-qt3support libqt4-sql lsb-qt4 qt4-designer \
  qt4-dev-tools qt4-doc qt4-qtconfig uim-qt gcc libapt-pkg-perl resolvconf


/!\ *A Special Note:* If you are following this set of instructions on
a system where you already have Qt3 development tools installed, there will
be a conflict between Qt3 tools and Qt4 tools. For example, qmake will
point to the Qt3 version not the Qt4. Ubuntu Qt4 and Qt3 packages are
designed to live alongside each other. This means that for example if you
have them both installed you will have three qmake exe's:


  /usr/bin/qmake -> /etc/alternatives/qmake 
  /usr/bin/qmake-qt3
  /usr/bin/qmake-qt4 


The same applies to all other Qt binaries. You will notice above that the
canonical 'qmake' is managed by apt alternatives, so before we start to
build QGIS, we need to make Qt4 the default. To return Qt3 to default later
you can use this same process.

You can use apt alternatives to correct this so that the Qt4 version of
applications is used in all cases:


  sudo update-alternatives --config qmake
  sudo update-alternatives --config uic 
  sudo update-alternatives --config designer 
  sudo update-alternatives --config assistant 
  sudo update-alternatives --config qtconfig 
  sudo update-alternatives --config moc 
  sudo update-alternatives --config lupdate 
  sudo update-alternatives --config lrelease 
  sudo update-alternatives --config linguist 


Use the simple command line dialog that appears after running each of the
above commands to select the Qt4 version of the relevant applications.


	4.4. Install additional software dependencies required by QGIS
	==============================================================


  sudo apt-get install gdal-bin libgdal1-dev libgeos-dev proj libtool \
  libgdal-doc libhdf4g-dev libhdf4g-run autoconf2.13 automake1.9 python-dev \
  swig libgsl0-dev g++ libjasper-1.701-dev libtiff4-dev  subversion gsl-bin \
  libsqlite3-dev sqlite3 ccache make libpq-dev flex bison firefox 



	4.5. GRASS Specific Steps
	=========================

/!\ *Note:* If you don't need to build with GRASS support,  you can
skip this section.

Now you can install grass from dapper:


  sudo apt-get install grass libgrass-dev libgdal1-grass 



	4.6. Setup ccache (Optional)
	============================

You should also setup ccache to speed up compile times:


  cd /usr/local/bin 
  sudo ln -s /usr/bin/ccache gcc 
  sudo ln -s /usr/bin/ccache g++ 



	4.7. Prepare your development environment
	=========================================

As a convention I do all my development work in $HOME/dev/<language>, so in
this case we will create a work environment for C++ development work like
this:


  mkdir -p ${HOME}/dev/cpp 
  cd ${HOME}/dev/cpp 


This directory path will be assumed for all instructions that follow.


	4.8. Check out the QGIS Source Code
	===================================

There are two ways the source can be checked out. Use the anonymous method
if you do not have edit privaleges for the QGIS source repository, or use
  the developer checkout if you have permissions to commit source code
  changes.

1. Anonymous Checkout


  cd ${HOME}/dev/cpp 
  svn co https://svn.qgis.org/repos/qgis/trunk/qgis qgis


2. Developer Checkout


  cd ${HOME}/dev/cpp 
  svn co --username <yourusername> https://svn.qgis.org/repos/qgis/trunk/qgis qgis 


The first time you check out the source you will be prompted to accept the
qgis.org certificate. Press 'p' to accept it permanently:


  Error validating server certificate for 'https://svn.qgis.org:443':
     - The certificate is not issued by a trusted authority. Use the
       fingerprint to validate the certificate manually!  Certificate
       information:
     - Hostname: svn.qgis.org
     - Valid: from Apr  1 00:30:47 2006 GMT until Mar 21 00:30:47 2008 GMT
     - Issuer: Developer Team, Quantum GIS, Anchorage, Alaska, US
     - Fingerprint:
       2f:cd:f1:5a:c7:64:da:2b:d1:34:a5:20:c6:15:67:28:33:ea:7a:9b (R)eject,
       accept (t)emporarily or accept (p)ermanently?  



	4.9. Starting the compile
	=========================

I compile my development version of QGIS into my ~/apps directory to avoid
conflicts with Ubuntu packages that may be under /usr. This way for example
you can use the binary packages of QGIS on your system along side with your
development version. I suggest you do something similar:


  mkdir -p ${HOME}/apps 


The script will carry on to build QGIS - it may take a little while to go
and have a cup of your favourite beverage while you wait...


	4.10. Running QGIS
	==================

Once the compile is complete it should pop up a page in firefox with unit
test results. At the time of writing the unit tests are just stubs - we
still need to create the test implementations - so dont worry to much about
their output at the moment.

Now you can try to run QGIS:


  $HOME/apps/bin/qgis 


If all has worked properly the QGIS application should start up and appear
on your screen.