[HelpOnLanguages] [TitleIndex] [WordIndex]

BuildingTerraLibUnderMingw

This page documents the process of building terralib under mingw.

1. Check out source code

/!\ This document assumes that all source code will be checked out under c:\dev\cpp\terralib

First create a working directory under c:\dev\cpp\terralib

Now using tortoise cvs, check out

cvs -d :pserver:anonymous@cvs.dpi.inpe.br:/home/terralib src

into c:\dev\cpp\terralib.

2. Install Qt4 with Mingw

We are going to be building using Qt4's qmake and mingw supplied with the Qt4 installation. Obtain the Qt4 installer from the Trolltech Downloads Page. Be sure to get the prebuilt binary with mingw, not the source bundle. For example when writing this document I retrieved a file called 'qt-win-opensource-4.2.2-mingw.exe (about 44 Mb)'.

When you run the installer be sure to check the option to download and install mingw.

3. Install CMake

We will be using cmake to build terralib and the modified tiff library supplied with terralib. Get the latest cmake windows installer from the cmake download page. When you install ensure that you allow it to add cmake to your path.

4. Build terralib

The terralib cvs server has the terralib sources and then 2 repositories containing project files for building under either windows (terralibw) or linux (terralibx).

 + terralib
  +---- src
  +---- terralibx
  +---- terralibw

However neither of the buildfile dirs supplied is suitable. The win dir has only Visual Studio projects and the linux version has qmake project files that dont build properly under qmake / mingw. Because of this we will use cmake build files I prepared to build the terralib modified version of libtiff and terralib. So before starting since we havent checked out terralibx and terralibw our source tree should look like this:

 + terralib
  +---- src

After we have finished, our source tree should look like this:

 + terralib
  +---- src
  +---- lib    <-- where the libs we are about to compile will go
  +---- build  <-- intermediate working dir for cmake

I created CMake project files for building libjpeg, libtiff and libterralib (terralib_cmake.zip). The zip file also contains libz.a which is needed for the build process. Extract this file over c:\dev\cpp\terralib. Once the files are extracted the file tree should look like this (excluding the sources you downloaded from cvs):

 + terralib
  +---- src
  |     CmakeList.txt
  +------ libjpeg 
  |        CmakeList.txt
  +------ terralib
  |       CmakeList.txt
  +------ tiff 
  |       CmakeList.txt
  +---- lib    <-- where the libs we are about to compile will go
  |     libz.a
  |     libmysqlclient.a
  +---- build  <-- intermediate working dir for cmake

Next open the qt4 command prompt e.g. Start -> Programs -> Qt by Trolltech v4.2.2 (OpenSource) -> Qt 4.2.2 Command Prompt

Now perform the following steps:

cd c:\dev\cpp\terralib\
mkdir build
cd build
cmakesetup ..

In the dialog that appears, click 'Configure'. At the 'Build For' prompt that appears, choose 'Mingw Makefiles' then 'Ok'. Now click 'Configure' again then 'Ok' again on the main cmakesetup dialog, then continue back at the command prompt:

make
make install

It should build and end with a message like this:

C:\dev\cpp\terralib\build>make install
[ 27%] Built target terratiff
[ 58%] Built target terrajpeg
[100%] Built target terralib
Install the project...
-- Install configuration: ""
-- Install configuration: ""
-- Installing c:/msys/local/lib/libterratiff.dll
-- Install configuration: ""
-- Installing c:/msys/local/lib/libterrajpeg.dll
-- Install configuration: ""
-- Installing c:/msys/local/lib/libterralib.dll

2014-08-13 10:44