Learning Objective:
In this short guide you will learn how to set up SeqAn and how to compile a small example to test whether everything works.
Difficulty
Easy
Duration
30 Minutes
Prerequisite tutorials
No prerequisites
Recommended reading
Software
Requirements:
gcc >= 12 or clang >=17 or IntelOneAPI >= 2024.0
cmake >= 3.20
git
Installing a compiler
VisualStudio/MSVC is not yet supported. We will briefly explain how to install a compiler on some popular operating systems. We recommend using the latest version of the compiler. For more information, refer to your operating system's documentation.
This will put GCC in a separate environment conda_gcc_env which can be activated via conda activate conda_gcc_env and deactivated via conda deactivate.
The Windows Subsystem for Linux offers an easy way to run a Linux distribution under Windows. Follow Microsoft's setup guide to install WSL and then follow the steps listed for Linux-based systems.
Browser
gitpod.io allows you to edit, compile and run code from within your browser. The free version includes 50 hours of use per month, which is plenty for our tutorials. A GitHub account is required. Click here to open SeqAn3 in gitpod.
GitHub Codespaces offer a service similar to gitpod, including a free monthly quota. Click here to open SeqAn3 in Codespaces.
Attention
After installing, g++ --version should print the desired GCC version. If not, you may have to use, for example, g++-14 --version or even specify the full path to your compiler.
Similarly, you may need to install CMake and git, e.g. apt install cmake git.
Directory Structure
In this section we will use the tree command to show the directory structure. This program may not be installed on your system. If so, you may wish to install it or verify the directory structure in other ways, e.g. by using ls -l.
For this project, we recommend following directory layout:
tutorial
├── source
├── build
└── seqan3
To set these directories up you can follow this script:
mkdir tutorial
cd tutorial
mkdir build
mkdir source
git clone https://github.com/seqan/seqan3.git
The output of the command tree -L 2 should now look like this:
.
├── build
├── seqan3
│ ├── CHANGELOG.md
│ ├── CMakeLists.txt
│ ├── ...
│ └── test
└── source
8 directories, 6 files
Compiling and Running
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:
// SPDX-FileCopyrightText: 2006-2025 Knut Reinert & Freie Universität Berlin
// SPDX-FileCopyrightText: 2016-2025 Knut Reinert & MPI für molekulare Genetik
The output should be Hello World!. Note that the build type is specified with -DCMAKE_BUILD_TYPE=Release. Specifying Release enables an optimized build where no debug information is available. Release mode is therefore suitable for the end user. Programs built using -DCMAKE_BUILD_TYPE=Debug will run slower, but also make the detection of errors easier. Debug is suitable for contributors, and we recommend using it while working with our Tutorials.
Remarks
Depending on the standard C++ compiler on your system, you may need to specify the compiler via -DCMAKE_CXX_COMPILER=, for example:
If you create a new cpp file and want to compile it, you need to add another add_executable and target_link_libraries directive to you CMakeLists.txt. For example, after adding another_program.cpp your CMakeLists.txt may look like this:
cmake_minimum_required (VERSION 3.20...3.31)
project (seqan3_tutorial CXX)
# add seqan3 to search path
list (APPEND CMAKE_PREFIX_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../seqan3/cmake")
# require seqan3 with a version between >=3.0.0 and <4.0.0
where <conda_install_path> must be replaced by the path yo your conda installation.
Usually this corresponds to the path printed by conda info --base and may look similar to /home/user/miniconda3/.
Assembler not found:... could not understand flag m ...
Try adding /usr/bin to your PATH:
export PATH=/usr/bin:$PATH
and run cmake again.
Incorrect compiler: Your compiler is not supported. or Only GCC is supported.
The incorrect compiler is used (e.g., Apple Clang instead of GCC). Be sure to set -DCMAKE_CXX_COMPILER=. For an example, see this remark.