SeqAn3  3.0.1
The Modern C++ library for sequence analysis.
Quick Setup (using CMake)

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.

Duration30 Minutes
Prerequisite tutorialsNo prerequisites
Recommended reading



  • gcc >= 7
  • cmake >= 3.4
  • git

SeqAn3 requires a compiler with full C++20 support or GCC >= 7. Current versions of LLVM/Clang and VisualStudio/MSVC are not supported. 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

sudo apt install g++

Ubuntu < 18.04

sudo add-apt-repository ppa:ubuntu-toolchain-r/test
sudo apt update
sudo apt install g++-7

MacOS using Homebrew

brew install gcc@7

MacOS using MacPorts

sudo port install gcc-7

Linux using conda

conda create -n gcc7 -c quantstack gcc-7 libgcc-7
conda activate gcc7

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.

Known Issue: If you encounter the error /usr/lib/x86_64-linux-gnu/ version 'CXXABI_1.3.11' not found, you have to set the LD_LIBRARY_PATH:
export LD_LIBRARY_PATH=/home/user/miniconda3/envs/gcc7/lib/
where /home/user/miniconda3/ is the path to your conda installation.
After installing, 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 and git, e.g. apt install cmake git.

Directory Structure

For this project, we recommend following directory layout:

├── source
├── build
└── seqan3

To set these directories up you can follow this script (note the --recurse-submodules when cloning SeqAn3):

mkdir tutorial
cd tutorial
mkdir build
mkdir source
git clone --recurse-submodules

The directory should now look like this:

├── source
├── build
└── seqan3
├── build_system
├── doc
├── include
├── submodules
└── test

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:

int main()
seqan3::debug_stream << "Hello world\n";
return 0;

To compile it we first create a CMakeLists.txt file in the source directory:

cmake_minimum_required (VERSION 3.4)
project (seqan3_tutorial CXX)
set(SeqAn3_DIR "${CMAKE_SOURCE_DIR}/../seqan3/build_system")
find_package (SeqAn3 REQUIRED)
add_executable (hello_world hello_world.cpp)
target_link_libraries (hello_world seqan3::seqan3)

The directories should now look like this:

├── source
├── CMakeLists.txt
└── hello_world.cpp
├── build
└── seqan3

Now we can switch to the directory build and run:

cmake ../source

The output should be Hello world.

Depending on the standard C++ on your system, you may need to specify the compiler via -DCMAKE_CXX_COMPILER=, for example:
cmake ../source -DCMAKE_CXX_COMPILER=/path/to/executable/g++-7
In some situations it can happen that the correct assembler is not found. You will see an error during the cmake configuration that says something like: ... could not understand flag m .... In this case you can try to export the Path:
export PATH=/util/bin:$PATH
and try running cmake again.

Adding a new source file to your project

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.4)
project (seqan3_tutorial CXX)
set(SeqAn3_DIR "${CMAKE_SOURCE_DIR}/../seqan3/build_system")
find_package (SeqAn3 REQUIRED)
add_executable (hello_world hello_world.cpp)
add_executable (another_program another_program.cpp)
target_link_libraries (hello_world seqan3::seqan3)
target_link_libraries (another_program seqan3::seqan3)
Provides seqan3::debug_stream and related types.
debug_stream_type debug_stream
A global instance of seqan3::debug_stream_type.
Definition: debug_stream.hpp:39