Learning Objective:
In this short guide you will learn how to set up your work environment for working through this nancourse.
Difficulty | Easy |
---|---|
Duration | 30 Minutes |
Prerequisite tutorials | No prerequisites |
Recommended reading |
Requirements:
We will briefly explain how to install GCC-7 on some popular operating systems, but we recommend using the latest version of GCC available. For more information refer to your operating system's documentation.
Ubuntu >= 18.04
Ubuntu < 18.04
MacOS using Homebrew
MacOS using MacPorts
Linux using conda
This will put GCC-7 in a separate environment called gcc7
which can be activated via conda activate gcc7
and deactivated via conda deactivate gcc7
.
/usr/lib/x86_64-linux-gnu/libstdc++.so.6: version 'CXXABI_1.3.11' not found
, you have to set the LD_LIBRARY_PATH: /home/user/miniconda3/
is the path to your conda installation. g++ --version
should print the desired version. If not, you may have to use, for example, g++-7 --version
or even specify the full path to your executable.Similarly you need to install cmake, e.g. apt install cmake
.
For this project, we recommend the following directory layout:
To create these directories, you can follow this script:
Now we need to create a file named CMakeLists.txt
inside source
with the following contents:
Alternatively, you can download the file here.
To test whether everything works, we will now compile and run a small example.
First we create the file hello_world.cpp
in the source
directory with the following contents:
Alternatively, you can download the file here.
To compile it, we run the following commands inside the build
directory:
The output should be Hello world
.
-DCMAKE_CXX_COMPILER=
, for example: ... could not understand flag m ...
. In this case you can try to export the Path: For example, to add the new task1.cpp
file to your CMakeLists.txt
, append the following line to your file:
To compile the new file, run cmake .
and make
inside the build
folder.