Assignment 0

Basic setup and knowledge for the course

Deadline is

Late submission? 10% will be removed for each day that you are late.

The assignment is worth 20% of your final mark.

The course assignments will be based on C++. If you need a refresher, this is a good series of tutorials. The same website is also a very good reference for the C++ standard library data structures, functions and algorithms. For example, if you want to know the member functions of a list or a map.

Please use the following instructions to have working system to compile C++ files with external libraries. It will be useful to hit the ground running in week 2.

If you want to test your setup, how about you use one of the GDAL tutorials or CGAL examples (eg this one with polygons).

How to install C++ libraries?

The simplest way to install libraries like CGAL or GDAL depends on your operating system. See the sections below.

Windows

The simplest way under Windows is… to install Linux!?

Installing all the libraries listed above is possible directly under Windows, but it is often a massive pain, so we recommend you use WSL—Windows Subsystem for Linux, which installs a Linux environment “inside” Windows (Win10 or Win11).

It works, and you can even use CLion (the Windows version) and use the compiler/libraries/debugger from WSL.

Just follow this tutorial, which also covers the installation of CMake and GDB. If something doesn’t work, please ask Özge, she wrote the tutorial and is a pro!

Mac

The easiest way is to use Homebrew (recommended), although it’s quite easy to use an alternative like MacPorts or to install them manually (follow the Linux or Unix instructions if there are none for Mac).

An example to install CGAL with Homebrew:

brew install cgal

The paths used by Homebrew are: /usr/local/include (for headers) and /usr/local/lib (for libraries).

Linux

Use the package manager of your distribution (eg apt in Ubuntu/Debian) or install them manually.

An example to install CGAL with apt:

sudo apt-get install libcgal-dev

How to use C++ libraries?

Anything in the standard library works after including a header. For example, if you want to use std::cout and its << operator, you need include iostream:

#include <iostream> 

If you need to use an external library (eg CGAL or GDAL), you will first need to add the required paths during compilation and linking. If you use CMake, this is typically done in your CMakeLists file by first calling a script that finds the library. An example using GDAL:

find_package( GDAL )

Which sets a number of variables with the required paths. Then, to set the include path, you can add something like:

include_directories( ${GDAL_INCLUDE_DIR} )

And the same for the library path:

target_link_libraries(your_program_name ${GDAL_LIBRARY} )

Only after those steps, adding the required headers in your .cpp file will work:

#include "gdal_priv.h"

Useful software for the course