Skip to content

Building and Configuring

Rodrigo Avancini edited this page Apr 23, 2019 · 51 revisions

How to Build TerraME

This small tutorial describes the steps to build and configure TerraME from its source code. In all the platforms, TerraME depends on the external packages and libraries listed bellow. They must be installed separately.

Mandatory

Optional

Instructions

Mac OSX (ref. OS X El Capitan)

CMake 3.X (ref. 3.12.2)

Download CMake and put cmake command in the PATH environment variable:

export PATH=$PATH:/path/to/cmake/bin  

Xcode (ref. 7.3)

To build TerraME and TerraLib components in Mac OSX environment you must install Xcode (found in AppStore) as well as Xcode command-line tools (https://developer.apple.com/downloads/index.action?=command%20line%20tools).

TerraME 2.X

Clone TerraME from git:

https://github.com/TerraME/terrame.git

It is recommended to create a structure of directories like:

-- terrame
     |
      -- 3rdparty
      -- build-cmake
      -- git
          |
           -- terrame (clone here)

TerraLib 5.X (ref. release-5.4)

Clone TerraLib from git. If you are using Sourcetree, go to Sourcetree, Preferences, Git, and then check Disable SSL certificate validation (note: potentially insecure) to allow downloading TerraLib.

Clone TerraLib from the following Git repository:

https://gitlab.dpi.inpe.br/rodrigo.avancini/terralib.git

Checkout the branch release-5.4, mandatorily.

It is recommended to create a structure of directories like:

-- terralib
     |
      -- 3rdparty
      -- build-cmake
      -- git
          |
           -- terralib (clone here)

TerraLib third parties

Compile the dependencies of TerraLib folowing the instructions available at Mac OS X found here.

It is recommended to use the structure of directories as follows:

-- terralib
     |
      -- 3rdparty
          |
           -- terralib-3rdparty-macosx-el-capitan.tar.gz (put here)
           -- install-3rdparty-macosx-el-capitan.sh (put here) (from /terralib/install)
           -- libs (here is TERRALIB_DEPENDENCIES_DIR)
      -- build-cmake
      -- git 

If you need credentials to download the TerraLib dependencies, put this:

user = terralib5 
password = newterralib5

Or use this command:

wget --user=terralib5 --password=newterralib5 http://www.dpi.inpe.br/terralib5-devel/3rdparty/src/5.4/terralib-3rdparty-macosx-el-capitan.tar.gz

Run install-3rdparty-macosx-el-capitan.sh to compile and install all TerraLib dependencies with this command:

TERRALIB_DEPENDENCIES_DIR="/.../terralib/3rdparty/libs" ./install-3rdparty-macosx-el-capitan.sh

TerraLib building

Copy the scripts terralib-conf.cmake and terralib-conf.sh from .../terrame/git/terrame/build/scripts to .../terralib/build-cmake

-- terralib
     |
      -- 3rdparty
      -- build-cmake
          |
           -- terralib-conf.cmake (put here)
           -- terralib-conf.sh (put here)
      -- git 

In terralib-conf.sh, set the variable:

export _TERRALIB_3RDPARTY_DIR=/.../terralib/3rdparty/libs

Go to .../terralib/build-cmake and run terralib-conf.sh.

After that, the build directory that contains the TerraLib Xcode project terralib.xcodeproj and an /install that contains all libraries of TerraLib will be created:

-- terralib
     |
      -- 3rdparty
      -- build-cmake
          |
           -- terralib-conf.cmake
           -- terralib-conf.sh
           -- build (created)
           -- install (created)
      -- git 

Protobuf (3.1.0)

Download zip protobuf from the following Git repository (you do not need to clone it):

https://github.com/google/protobuf/releases/tag/v3.1.0

It is recommended to use the structure of directories created:

-- terrame
     |
      -- 3rdparty
          |
           -- protobuf (put here)
      -- build-cmake
      -- git 

Luacheck (ref 0.17.0)

Download tar.gz luacheck from the following repository releases (you do not need to clone it):

https://github.com/mpeterv/luacheck/releases

It is recommended to use the structure of directories created:

-- terrame
     |
      -- 3rdparty
          |
           -- protobuf
           -- luacheck (extract here and rename)
      -- build-cmake
      -- git 

Copy the script terrame-deps-conf.sh from .../terrame/git/terrame/build/scripts to .../terrame/3rdparty.

-- terrame
     |
      -- 3rdparty
          |
           -- protobuf
           -- luacheck
           -- terrame-deps-conf.sh (put here)
      -- build-cmake
      -- git 

Run terrame-deps-conf.sh. After that, the /install directory that contains the necessary libraries to compile TerraME will be created.

TerraME 2.X (ref. 2.0)

Copy the scripts terrame-conf.cmake and terrame-conf.sh from .../terrame/git/terrame/build/scripts to .../terrame/build-cmake

-- terrame
     |
      -- 3rdparty
      -- build-cmake
          |
           -- terrame-conf.cmake (put here)
           -- terrame-conf.sh (put here)
      -- git 

In terrame-conf.sh, set the variables:

export _TERRALIB_3RDPARTY_DIR=/.../terralib/3rdparty/libs
export _TERRAME_DEPENDS_DIR=/.../terrame/3rdparty/install
export _TERRALIB_MODULES_DIR=/.../terralib/build-cmake/install
export _QT5_DIR=/path/to/qt5/version

Go to .../terrame/build-cmake and run terrame-conf.sh.

After that, the build directory that contains the TerraME Xcode project terrame.xcodeproj and the directory install, that contains all libraries and executable of TerraME, will be created:

-- terrame
     |
      -- 3rdparty
      -- build-cmake
          |
           -- terrame-conf.cmake
           -- terrame-conf.sh
           -- install (created here)
           -- build (created here)
      -- git 

To run TerraME, it is necessary to set some paths in environment or to create a ~/.bash_profile like:

export TME_ROOT_PATH=/.../terrame/build-cmake/install
export TME_PATH=$TME_ROOT_PATH/bin
export DYLD_LIBRARY_PATH=$TME_ROOT_PATH/lib

Run terrame command from the terminal to see if everything went fine:

terrame -version

Compile TerraME as Bundle

See Bundle Structures on Mac Page for details about Bundle.

In terrame-conf.cmake, set TERRAME_BUILD_AS_BUNDLE to ON. Be careful not to have it defined as an environmental variable or in your ~/.bash_profile.

Go to .../terrame/build-cmake and run terrame-conf.sh.

After that, a bundle of TerraME in /install directory will exist. To work with bundle, it is necessary to set PATH environment variable to .../bin within TerraME directory or set this command in ~/.bash_profile:

export PATH=$PATH:/.../terrame/build-cmake/install/terrame.app/Contents/bin

Run terrame command in terminal for test:

terrame -version

Create TerraME installer DMG

With bundle enabled, it is only necessary to run the command in build directory:

cd /.../terrame/build-cmake/build && /Applications/CMake.app/Contents/bin/cpack -G DragNDrop -C Release --config ./CPackConfig.cmake

Ms Windows (ref. 8.1 x64)

CMake 3.X (ref. 3.12.2)

Download CMake and put cmake command in the PATH environment variable:

set PATH=%PATH%;path\to\cmake\bin  

Ms Visual Studio (ref. 2017)

To build TerraME and TerraLib components in Windows you need to install Ms Visual Studio 2017.

TerraME 2.X

Clone TerraME from git:

https://github.com/TerraME/terrame.git

It is recommended to create a structure of directories like the one below:

-- terrame
     |
      -- 3rdparty
      -- build-cmake
      -- git
          |
           -- terrame (clone here)

TerraLib 5.X (ref. release-5.4)

Clone TerraLib from git. If you are using Sourcetree, go to Sourcetree, Preferences, Git, and then check Disable SSL certificate validation (note: potentially insecure) to allow downloading TerraLib. Clone it from the following Git repository:

https://gitlab.dpi.inpe.br/rodrigo.avancini/terralib.git

Checkout the branch release-5.4, mandatorily.

It is recommended to create a structure of directories like the one below:

-- terralib
     |
      -- 3rdparty
      -- build-cmake
      -- git
          |
           -- terralib (clone here)

TerraLib third parties

Compile the dependencies of TerraLib folowing the instructions available at Ms Windows found here.

It is recommended to use the structure of directories like the one below:

-- terralib
     |
      -- 3rdparty
          |
           -- terralib-3rdparty-msvc17 (extract here)
           -- build_all.bat
           -- build_all_x64.bat
      -- build-cmake
      -- git 

If you need credentials to download TerraLib dependencies, use:

user = terralib5 
password = newterralib5

Set the variables in build_all.bat:

IF DEFINED TERRALIB_X64 (
set TERRALIB_DEPENDENCIES_DIR=\...\terralib\3rdparty\libs
set QMAKE_FILEPATH=C:\Qt\{VERSION}\msvc2017_64\bin
)

Run build_all_x64.bat to compile and install all TerraLib dependencies.

TerraLib building

Copy the scripts terralib-conf.cmake and terralib-conf.bat from .../terrame/git/terrame/build/scripts to .../terralib/build-cmake

-- terralib
     |
      -- 3rdparty
      -- build-cmake
          |
           -- terralib-conf.cmake (put here)
           -- terralib-conf.bat (put here)
      -- git 

In terralib-conf.bat, set the variable:

export _TERRALIB_3RDPARTY_DIR=/.../terralib/3rdparty/libs

Go to .../terralib/build-cmake and run terralib-conf.bat.

After that, a build directory that contains the TerraLib MSVC solution terralib.sln and install that contains all libraries will created:

-- terralib
     |
      -- 3rdparty
      -- build-cmake
          |
           -- terralib-conf.cmake
           -- terralib-conf.bat
           -- build (created)
           -- install (created)
      -- git 

Luacheck (ref 0.17.0)

Download zip luacheck from the following repository releases (you do not need to clone it):

https://github.com/mpeterv/luacheck/releases

It is recommended to use the structure of directories created:

-- terrame
     |
      -- 3rdparty
          |
           -- luacheck (extract here and rename)
      -- build-cmake
      -- git 

Copy the script terrame-deps-conf.bat from .../terrame/git/terrame/build/scripts to .../terrame/3rdparty.

-- terrame
     |
      -- 3rdparty
          |
           -- luacheck
           -- terrame-deps-conf.bat (put here)
      -- build-cmake
      -- git 

Run terrame-deps-conf.bat.

After run, a install directory that contains LuaCheck will exist.

Protobuf (ref. 3.1.0)

Download zip protobuf from the following Git repository (you do not need to clone it):

https://github.com/google/protobuf/releases/tag/v3.1.0

It is recommended to use the created structure of directories:

-- terrame
     |
      -- 3rdparty
          |
           -- luacheck
           -- terrame-deps-conf.bat
           -- protobuf (extract here and rename)
      -- build-cmake
      -- git 

Run terrame-deps-conf.bat. After that, the /install directory that contains the necessary libraries to compile TerraME will be created.

MSYS2

Download msys2-x86_64-XXX.exe. Install MSYS2, open msys.exe terminal update msys and install zip and unzip commands:

pacman -Syu (note: run this command 2 times)
pacman -S zip unzip

TerraME 2.X (ref. 2.0)

Copy the scripts terrame-conf.cmake and terrame-conf.bat located in .../terrame/git/terrame/build/scripts to .../terrame/build-cmake

-- terrame
     |
      -- 3rdparty
      -- build-cmake
          |
           -- terrame-conf.cmake (put here)
           -- terrame-conf.bat (put here)
      -- git 

In terrame-conf.bat, set the variables:

set _TERRALIB_3RDPARTY_DIR=...\terralib\3rdparty\libs
set _TERRAME_DEPENDS_DIR=...\terrame\3rdparty\install
set _TERRALIB_MODULES_DIR=...\terralib\build-cmake\install
set _QT5_DIR=path\to\qt5\version\msvc2017_64
set _MSYS_DIR=C:\msys64\usr\bin

Go to .../terrame/build-cmake and run terrame-conf.bat.

After that, a build that contains the TerraME Visual Studio soluction terrame.sln and a directory install that contains all libraries and executable of TerraME will be created:

-- terrame
     |
      -- 3rdparty
      -- build-cmake
          |
           -- terrame-conf.cmake
           -- terrame-conf.bat
           -- build (created here)
           -- install (created here)
      -- git 

To run the TerraME, it is necessary set some paths in environment like:

set TME_PATH=.../terrame/build-cmake/install/bin
set PATH=%PATH%;%TME_PATH%

Run terrame command in terminal for test:

terrame -version

Compile TerraME as Bundle

In terrame-conf.cmake, set TERRAME_BUILD_AS_BUNDLE to ON.

Go to .../terrame/build-cmake and run terrame-conf.bat.

To run the TerraME, it is necessary set some paths in environment like:

set TME_PATH=.../terrame/build-cmake/install/bin
set PATH=%PATH%;%TME_PATH%

Run terrame command in terminal for test:

terrame -version

Create TerraME installer

Firtly, download end install NSYS (ref. 2.50).

With bundle enabled, it is only necessary build PACKAGE in Visual Studio:

The installer is generated in .../terrame/build-cmake/build directory.

Linux environment (ref. Ubuntu 14.04 LTS)

CMake 3.X (ref. 3.12.2)

sudo apt-get install build-essential
wget http://www.cmake.org/files/v3.2/cmake-3.12.2.tar.gz
tar xf cmake-3.12.2.tar.gz
cd cmake-3.12.2
./configure
make -j4
sudo make install

TerraME 2.X

Clone TerraME from git:

https://github.com/TerraME/terrame.git

It is recommended to create a structure of directories like:

-- terrame
     |
      -- 3rdparty
      -- build-cmake
      -- git
          |
           -- terrame (clone here)

TerraLib 5.X (ref. release-5.4)

Clone TerraLib from the following Git repository:

https://gitlab.dpi.inpe.br/rodrigo.avancini/terralib.git

Checkout the branch release-5.4, mandatorily.

If you get a certificate verification error, open terminal and put this command:

git config --global http.sslVerify false

It is recommended to create a structure of directories like:

-- terralib
     |
      -- 3rdparty
      -- build-cmake
      -- git
          |
           -- terralib (clone here)

TerraLib third parties

Compile the dependencies of TerraLib folowing the instructions available at Linux Ubuntu 14.04 found here*.

It is recommended to use the structure of directories as follows:

-- terralib
     |
      -- 3rdparty
          |
           -- terralib-3rdparty-linux-ubuntu-14.04.tar.gz (put here)
           -- install-3rdparty-linux-ubuntu-14.04.sh (put here) (from /terralib/install)
           -- libs (here is TERRALIB_DEPENDENCIES_DIR)
      -- build-cmake
      -- git 

If you need credentials to download the TerraLib dependencies, put this:

user = terralib5 
password = newterralib5

Or use this command:

wget --user=terralib5 --password=newterralib5 http://www.dpi.inpe.br/terralib5-devel/3rdparty/src/5.4/terralib-3rdparty-linux-ubuntu-14.04.tar.gz

Run install-3rdparty-linux-ubuntu-14.04.sh to compile and install all TerraLib dependencies with this command:

TERRALIB_DEPENDENCIES_DIR="/.../terralib/3rdparty/libs" ./install-3rdparty-linux-ubuntu-14.04.sh

TerraLib building

Copy the scripts terralib-conf.cmake and terralib-conf.sh from .../terrame/git/terrame/build/scripts to .../terralib/build-cmake

-- terralib
     |
      -- 3rdparty
      -- build-cmake
          |
           -- terralib-conf.cmake (put here)
           -- terralib-conf.sh (put here)
      -- git 

In terralib-conf.sh, set the variable:

export _TERRALIB_3RDPARTY_DIR=/.../terralib/3rdparty/libs

Go to .../terralib/build-cmake and run terralib-conf.sh.

After that, the build and install directory that contains the project and all libraries of TerraLib will be created:

-- terralib
     |
      -- 3rdparty
      -- build-cmake
          |
           -- terralib-conf.cmake
           -- terralib-conf.sh
           -- build (created)
           -- install (created)
      -- git 

Protobuf (ref. 3.1.0)

Download zip protobuf from the following Git repository (you do not need to clone it):

https://github.com/google/protobuf/releases/tag/v3.1.0

It is recommended to use the structure of directories created:

-- terrame
     |
      -- 3rdparty
          |
           -- protobuf (put here)
      -- build-cmake
      -- git 

Luacheck (ref 0.17.0)

Download tar.gz luacheck from the following repository releases (you do not need to clone it):

https://github.com/mpeterv/luacheck/releases

It is recommended to use the structure of directories created:

-- terrame
     |
      -- 3rdparty
          |
           -- protobuf
           -- luacheck (extract here and rename)
      -- build-cmake
      -- git 

Copy the script terrame-deps-conf.sh from .../terrame/git/terrame/build/scripts/linux to .../terrame/3rdparty.

-- terrame
     |
      -- 3rdparty
          |
           -- protobuf
           -- luacheck
           -- terrame-deps-conf.sh (put here)
      -- build-cmake
      -- git 

Run terrame-deps-conf.sh. After that, the /install directory that contains the necessary libraries to compile TerraME will be created.

TerraME 2.X (ref. 2.0)

Copy the scripts terrame-conf.cmake and terrame-conf.sh from .../terrame/git/terrame/build/scripts to .../terrame/build-cmake

-- terrame
     |
      -- 3rdparty
      -- build-cmake
          |
           -- terrame-conf.cmake (put here)
           -- terrame-conf.sh (put here)
      -- git 

In terrame-conf.sh, set the variables:

export _TERRALIB_3RDPARTY_DIR=/.../terralib/3rdparty/libs
export _TERRAME_DEPENDS_DIR=/.../terrame/3rdparty/install
export _TERRALIB_MODULES_DIR=/.../terralib/build-cmake/install
export _QT5_DIR=/path/to/qt5

Go to .../terrame/build-cmake and run terrame-conf.sh.

After that, the build and install directory that contains the TerraME will be created:

-- terrame
     |
      -- 3rdparty
      -- build-cmake
          |
           -- terrame-conf.cmake
           -- terrame-conf.sh
           -- build (created here)
           -- install (created here)
      -- git 

To run TerraME, it is necessary to set some paths in environment or append in ~/.bashrc like:

export TME_PATH=/.../terrame/build-cmake/install/bin
export PATH=$PATH:$TME_PATH
export LD_LIBRARY_PATH=$TME_PATH

Run terrame command from the terminal to see if everything went fine:

terrame -version

Create TerraME installer

With everything built, it is only necessary to run the command in build directory:

cd /.../terrame/build-cmake/build && cpack -G TGZ -C Release --config ./CPackConfig.cmake