Skip to content
maybites edited this page Jan 27, 2021 · 40 revisions

Welcome to the build from source wiki!

There several options to build libossia depending on your need. For example you can build only ossia-max if your are only interested in it. Or you can build all implementations add optional modules at once if you want. Each element in the following list should be independent from each other.

Table of content

Building libossia and tests on macOS with QtCreator

  • libossia requires Xcode 10.
  • Install Homebrew
  • In a terminal, run the following.
brew update
brew install wget cmake
git clone --recursive https://github.com/OSSIA/libossia

Then in QtCreator, open libossia/CMakeLists.txt.

Note : If QtCreator complains about CMake, be sure to follow this set-up guide.

To enable the tests and examples, once the project is open:

  • Go to the Projects pane on the left bar
  • In the list of Settings - Values, check OSSIA_TESTING and OSSIA_EXAMPLES
  • Press "Apply Configuration Changes"

Building libossia and tests on macOS on the command line

  • libossia requires Xcode 10.
  • Install Homebrew
  • In a terminal, run the following.
brew update
brew install wget cmake
git clone --recursive https://github.com/OSSIA/libossia
  • Make a build folder
mkdir libossia-build
cd libossia-build
cmake ../libossia -DOSSIA_EXAMPLES=1 -DOSSIA_TESTING=1 
make -j4 # or more depending on your number of CPU cores

Building libossia & tests on MS Windows with Visual Studio

  • Ensure that you have the latest Visual Studio installed and up-to-date (at least 2019).

  • Clone the repository with your favorite Git client, the needed submodules will be cloned by CMake when configuring. The command line version is :

git clone --recursive https://github.com/OSSIA/libossia
  • You can either use the CMake integration shipping with Visual Studio (open the CMakeLists.txt file in VS), or install and run CMake manually. In that case, here are the additional following steps leading to a build :

  • Install CMake or update it if you have not already. Be sure to add it to PATH when the installer asks for it.

  • Run a Visual Studio command prompt (for instance VS2019 x64 Native Tools).

  • Find and save where the various libraries you installed are. For instance:

set LIBOSSIA_DIR=c:\Users\Myself\GitHub\libossia # Where libossia was cloned.
  • Create a build folder, and inside, run :
cmake -DOSSIA_EXAMPLES=1 -DOSSIA_TESTING=1 "%LIBOSSIA_DIR%"

Now CMake should have generated a Visual Studio solution (.sln) in this folder, that you can use for compiling and running.

Building the PureData external for Raspberry Pi 2/3 :

The Docker way

The Docker image is an ARM image. It means that the host must support executing ARM code. Thankfully, qemu allows just that. First install the binfmt-support package (name may vary across ARM distro). Then:

update-binfmts --enable qemu-arm

docker pull iscore/iscore-rpi-sdk:latest
docker run --name ossia -it iscore/iscore-rpi-sdk /bin/bash

In the docker image :

export PATH=/opt/gcc-6/bin:/opt/cmake/bin:$PATH
export LD_LIBRARY_PATH=/opt/gcc-6/lib

git clone --recursive https://github.com/OSSIA/libossia

(
  mkdir -p build; cd build
  cmake ../libossia \
      -DCMAKE_C_COMPILER=/opt/gcc-6/bin/gcc \
      -DCMAKE_CXX_COMPILER=/opt/gcc-6/bin/g++ \
      -DCMAKE_SHARED_LINKER_FLAGS="-static-libstdc++" \
      -DOSSIA_STATIC=1
  make -j8
)

In the host :

docker cp ossia:/build/OSSIA/ossia-pd/ossia.l_arm .

For reference, here is an ArchLinux set-up guide for ARM qemu + Docker.

The cross-compilation way

From a Linux environment it's quite easy to cross-compile for another processor architecture, giving that you have a ready-to-use sysroot. This is what we are giving to you. You can download and setup a cross-compiling toolchain with the following steps :

        wget -nv https://www.dropbox.com/s/lwchd3va49sd43p/gcc-8.2.0-rpi.tar.bz2
        tar xf gcc-8.2.0-rpi.tar.bz2 
        sudo mv cross-pi-gcc-8.2.0/ /opt/
        sudo ln -s /opt/cross-pi-gcc-8.2.0 /opt/cross-pi-gcc

        sudo ln -s /usr/include/arm-linux-gnueabihf/sys /usr/include/sys
        sudo ln -s /usr/include/arm-linux-gnueabihf/bits /usr/include/bits
        sudo ln -s /usr/include/arm-linux-gnueabihf/gnu /usr/include/gnu
        sudo ln -s /usr/include/arm-linux-gnueabihf/asm /usr/include/asm
        sudo ln -s /usr/lib/arm-linux-gnueabihf/crti.o /usr/lib/crti.o
        sudo ln -s /usr/lib/arm-linux-gnueabihf/crt1.o /usr/lib/crt1.o
        sudo ln -s /usr/lib/arm-linux-gnueabihf/crtn.o /usr/lib/crtn.o

Then add the compiler to your path and configure the project :

  export PATH=/opt/cross-pi-gcc/bin:${PATH}
  export LD_LIBRARY_PATH=/opt/cross-pi-gcc/lib:${LD_LIBRARY_PATH}

  mkdir build-libossia-pd-rpi # inside the libossia folder
  cd build-libossia-pd-rpi
  cmake -DCMAKE_TOOLCHAIN_FILE="$PWD/../CMake/toolchain/arm-linux-gnueabihf.cmake" \
                   -DCMAKE_BUILD_TYPE=Release \
                   -DCMAKE_INSTALL_PREFIX="$TRAVIS_BUILD_DIR" \
                   -DOSSIA_CI=1 \
                   -DOSSIA_PD_ONLY=1 \
                   -DCMAKE_INSTALL_PREFIX="${PWD}/install"
                   ..
  cmake --build .
  cmake --build . --target install

This example is for ossia-pd but you can change the option for the other implementations. Look at our continuous integration script for more example : https://github.com/OSSIA/libossia/tree/master/ci And feel free to get in touch with us on Gitter !

Building from Android

Requirements:

  • Android NDK. Last tested with NDK r14b.

Since version 3.7, CMake provides built-in Android support. A toolchain file is provided with libossia; it should be modified according to the installation path of the Android NDK.

To compile, run:

(
mkdir -p build; cd build
cmake ../libossia \
      -DCMAKE_TOOLCHAIN_FILE=../libossia/CMake/android_toolchain.cmake \
      -DCMAKE_BUILD_TYPE=Release \
      # If Qt bindings are used: \
      -DCMAKE_PREFIX_PATH=~/Qt/5.8/android_armv7/lib/cmake/Qt5/ \              
      -DCMAKE_SHARED_LINKER_FLAGS="-static-libstdc++" 

make -j8
)

Building the Max implementation on MacOS:

Max implementation of libossia on MacOS can be built following these steps. (Note that this assumes you want the Max implementation only. If you are interested in other implementations, please follow the steps at the top of this page.)

The long run

Setup
brew update
brew install wget cmake

You can then clone the libossia repository:

git clone --recursive https://github.com/OSSIA/libossia
Optional Max SDK setup

Max's SDK will be downloaded by CMake at configure time. If you want another version, place it into Max's package folder.

Building libossia for Max

Then run the following commands from the terminal:

cd libossia-folder
mkdir build-max 
cd build-max
cmake ../libossia -DOSSIA_MAX_ONLY=1 -DCMAKE_INSTALL_PREFIX="$PWD/ossia-install"
make -j8
make install -j8

If you want to distribute the build to other OS versions, add -DOSSIA_OSX_RETROCOMPATIBILITY=1 to the options

Then you should find the ossia-max under build-max/ossia-install/ossia-max-package folder. You can copy or symlink it to ~/Documents/Max 8/Package/ to load ossia at Max startup :

mkdir -p $HOME/Documents/Max\ 8/Packages/ossia/extensions
cd OSSIA/ossia-max
ln -s  ossia-max.mxo $HOME/Documents/Max\ 8/Packages/ossia/extensions/

The short run

All the steps above are concatenated in a script you can execute from a Terminal command line.

cd libossa-folder
cd tools
./build-ossia-max.sh

!!! WARNING !!! THIS WILL INSTALL AND UPGRADE HOMEBREW AUTOMATICALLY

Then you should have an ossia package in your ~/Documents/Max 8/Packages/ossia folder.

To build a release package, use the release option:

./build-ossia-max.sh release

To make a fresh build from scratch (as opposed to incremental build), use the clean option:

./build-ossia-max.sh clean

Building the Max implementation on Windows:

Setup

Ensure that you have the latest Visual Studio installed and up-to-date (at least 2019).

Max implementation of libossia on Windows can be built following these steps. (Note that this assumes you want the Max implementation only. If you are interested in other implementations, please follow the steps at the top of this page.)

Clone the libossia repository:

git clone --recursive https://github.com/OSSIA/libossia

Optional Max SDK setup

Max's SDK will be downloaded by CMake at configure time. If you want another version, place it into Max's package folder.

Building libossia for Max

Then run the following commands from the terminal:

mkdir build-max 
cd build-max
cmake ../libossia -G"Visual Studio 16 2019" -T host=x64 -DOSSIA_MAX_ONLY=1 -DCMAKE_INSTALL_PREFIX=ossia-install -Wno-dev
cmake --build . --config Release
cmake --build . --config Release --target INSTALL

Then you should find the ossia-max package under build-max/ossia-install/ossia-max-package folder. Copy the ossia folder inside ossia-install/ossia-max-package so that it ends up in your Max 8 packages folder (Documents/Max\ 8/Packages/)

Building ossia-pd:

Installing dependencies

    sudo apt-key adv --recv-keys --keyserver keyserver.ubuntu.com 1397BC53640DB551
    sudo add-apt-repository --yes ppa:ubuntu-toolchain-r/test
    sudo apt-get update
    sudo apt-get install --yes --force-yes cmake g++-7 binutils ninja-build gcovr lcov libasound2-dev clang-4.0 lld-4.0

Run the following commands from the terminal:

git clone --recursive https://github.com/OSSIA/libossia
mkdir build-pd
cd build-pd
cmake ../libossia -DOSSIA_PD_ONLY=1 -DOSSIA_PD_INSTALL_FOLDER="$HOME/pd-externals/ossia" -GNinja
ninja
ninja install

Depending on you platform you may need to specify another compiler with -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_COMPILER=gcc-7 -DCMAKE_CXX_COMPILER=g++-7 options for example. Then you should find a package under $HOME/pd-externals/ossia folder. Then open pd and add ossia to the libraries to load on startup and restart Pd.

Building ossia-python

On Mac

Tested on a Mac with Python installed via Homebrew

  • Python 2.7
    cmake .. -DOSSIA_PYTHON_ONLY=1 -DCMAKE_INSTALL_PREFIX=${PWD}/ossia-install -DPYTHON_LIBRARY=$(python-config --prefix)/lib/libpython2.7.dylib -DPYTHON_EXECUTABLE=/usr/local/bin/python2 -DPYTHON_INCLUDE_DIR=$(python-config --prefix)/include/python2.7

  • Python 3.6
    cmake .. -DOSSIA_PYTHON_ONLY=1 -DCMAKE_INSTALL_PREFIX=ossia-install -DPYTHON_LIBRARY=$(python3-config --prefix)/lib/libpython3.7.dylib -DPYTHON_EXECUTABLE=/usr/local/bin/python3 -DPYTHON_INCLUDE_DIR=$(python3-config --prefix)/include/python3.7

  • Python 2.7 & 3.6

make -j4

It will create a wheel in /your/build/folder/OSSIA/ossia-python/dist