FlexSEA Wiki


User Tools

Site Tools


Building fx_plan_stack from sources

This page will demonstrate how to compile the Windows libraries, and how to cross-compile the Raspberry Pi librairies from a Windows machine.


  • Git (version >= 1.47, we recommend using the latest stable version available on your platform)
  • Bash (Git bash works on Windows , just make sure it is the default to run .sh files)
  • CMake (version >= 3.13, can be either 32 or 64 bit version based on your system's architecture )
    • Get the latest version of CMake and add it to your path.
  • Ninja (version >= 1.3, can be either 32 or 64 bit version based on your system's architecture)
  • GCC 7.3. Do not use any other version.

Setup - Windows

  1. Start by installing CMake
    • Note the install path, you will need to add it to the PATH later.
  2. Next install GCC. Get a mingw64 installer from source forge.
    • Use the following setting when installing mingw64 .
    • Note the installation path and navigate to it. Go into the mingw32 folder and then the bin folder. Note this path, you will need to add it to the PATH later. That path should look like this: C:\Program Files (x86)\mingw-w64\i686-7.3.0-posix-dwarf-rt_v5-rev2\mingw32\bin
  3. Next install ninja
    1. Get the latest release (We use 1.90) and download it
    2. Unzip the file
    3. Place it the folder containing the ninja executable to your program files directory on Windows or your /usr/bin/ directory on Linux
    4. Add it to your path, this allows you to access any executables (such as Ninja, CMake and GCC) from the command line
      1. On Windows this is done using the advanced setting in the environment variables
      2. Navigate to advanced settings and select environment variables
      3. Select the PATH variable in system variables
      4. Then add the paths from the previous installs (note: MingW is not visible in the screenshot, but it needs to be listed)

Setup - Linux/Raspberry Pi

These are all the packages needed for Linux/Raspberry Pi

sudo apt-get install gcc
sudo apt-get install g++
sudo apt-get install cmake
sudo apt-get install ninja-build

How to build the fx_plan_stack libraries

  1. From your git bash console
  2. Start from a fresh version of the FlexSEA repo (currently on develop branch). For best results, ensure you have access to all FlexSEA submodules. You should anyway because if you change the fx_plan_stack you should copy the resulting libraries to Actuator-Package and plan_3_0 repos
    git clone --recursive https://github.com/DephyInc/FlexSEA.git 
  3. Change directory into FlexSEA
    cd FlexSEA
  4. Make sure all the required submodules are up to date
    git submodule update --init --recursive flexsea-core
    git submodule update --init --recursive flexsea-dephy
    git submodule update --init --recursive fx_plan_stack
    git submodule update --init --recursive Actuator-Package
    git submodule update --init --recursive plan_3_0
  5. Checkout empty submodules (only necessary if FlexSEA clone fails due to not having access to all FlexSEA repos)
    cd flexsea-dephy && git checkout && cd ..
    cd flexsea-core && git checkout && cd ..
    cd Actuator-Package && git checkout && cd ..
  6. Change directory into fx_plan_stack and run stack_builder.sh
    cd fx_plan_stack && ./stack_builder.sh 
  7. A successful build will print a message similar to
    [65/66]Linking CXX static library libs\libfx_plan_stack_static.a
    [66/66] Linking CXX shared library libs\libfx_plan_stack.dll
  8. If you are going to commit your library builds (i.e after a code change to the fx_plan_stack), please be sure to build for all supported platforms (currently Windows, Linux, and Raspberry Pi).
    1. Linux: To build for Linux on Windows 10, install Ubuntu emulator.
      1. Once installed, go to Bash command line and install dos2unix. It's needed to change stack_builder.sh line endings to Unix style:
        sudo apt-get update
        sudo apt-get install dos2unix
        sudo dos2unix <path_to_stack_builder.sh>
      2. Now navigate to folder [FlexSEA/fx_plan_stacks] and run:
        1. Make sure you've installed the required packages
      3. If you get a large number of error messages not related to missing packages, you might need to run with elevated privileges:
        sudo ./stack_builder.sh
    2. Raspberry Pi: To build for Raspberry Pi 4 on Windows or Linux:
      1. Open a Git Bash shell.
      2. Download the Raspberry Pi toolchain.
      3. Update the paths in your CMAKE_RASPBERRY_PI_TOOLCHAIN_FILE to point to your local Raspberry Pi compilers.
      4. Run:
        ./stack_builder.sh -pi 
      5. A successful build will print a message similar to
        [65/66]Linking CXX static library libs\libfx_plan_stack_static.a
        [66/66] Linking CXX shared library libs\libfx_plan_stack.so
  9. Successful builds automatically copy over to the Actuator Package and plan_3_0 repos within FlexSEA (this is to ensure Actuator Package is completely independent from fx_plan_stack)

Debug Build

If you wish to build a plan stack with debug info you can add one of these to the CMakeLists.txt:


To enforce release build:


Test the library:

  1. First, make sure that Actuator-Package\Python\flexseapython\com.txt has the right COM port.
  2. Navigate to the Actuator-Package\Python folder.
python fxMain.py


It is possible to use CLion for your fx_plan_stack development. As of now, it supports file navigation and syntax highlighting, as well as basic compilation.

  1. Open CLion
  2. File > Open…
  3. Select fx_plan_stack (top directory). If you already had another project open, select New Window.
    • Important: you need to have the submodules in the right location (side by side).
    • Easiest way to do this is to clone FlexSEA and to open FlexSEA\fx_plan_stack as your project.
  4. Confirm that the CMake project was loaded (lower console). You may have to remove some environment variable to make it work.

You can now use CLion as your IDE. As a quick test, open src/device.cpp. Ctrl+click on circ_buff_init() as a test; it will bring you to the flexsea-comm submodule.

Build and release configurations should be available automatically: Selecting fx_plan_stack and clicking build will compile your libraries.

Please keep in mind that stack_builder.sh does more than simply compile: it moves necessary files to where they belong. Exercise caution if you decide to build with CLion.

How to cross-compile the libraries

To be succinct, this section will only cover the differences compilation and cross compilation. For more detailed instructions on compilation, read the previous section.

To cross compile, you will need to have installed and configured the appropriate cross-compiler. Here are the cross compilers for:

After installing these toolchains, the appropriate toolchain file must be used. This file specifies where the toolchain is located and other build settings. These can be found in the git repositories root directory and are specific to the target system.

For the Raspberry Pi Toolchain for Unix systems, the appropriate toolchain path is


Note: Make sure the paths in these files are correct.

To use the toolchain with an existing Cmake list, just add the DCMAKE_TOOLCHAIN_FILE flag.


There are also batch files (i.e. cross_compile_RPI.bat) that automate the build process.


  1. For Windows, for all CMake steps, add -G “MinGW Makefiles”. Instead of simply calling
    cmake ..


    cmake .. -G "MinGW Makefiles"
  2. If 'make' doesn't work try using 'mingw32-make.exe' instead.
build_fx_plan.txt · Last modified: 2020/06/22 11:47 by sbelanger