Building

Antoine Villeret edited this page Sep 11, 2018 · 30 revisions

Welcome to the libossia wiki!

Table of content

Building libossia and tests on macOS with QtCreator

  • First, if you have OS X 10.12, ensure that you have the latest Xcode 8 installed and up-to-date. If you're not on 10.12 for some reasons, you can still build libossia yourself but you need to use GCC. You can install it from brew (brew install gcc) and then configure build to use it instead of Apple Clang.
  • Install Homebrew
  • In a terminal, run the following.

Note that if you're only interressed in ossia-pd, ossia-max or ossia-python, then you don't need Qt5. Just remove it from the brew install command line.

brew update
brew install wget cmake qt5
git clone 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"

If you are not on OS X 10.12, change CMAKE_C_COMPILER settings to gcc and CMAKE_CXX_COMPILER to g++ in project settings and then "Apply Configuration Changes".

Building libossia & tests on MS Windows with Visual Studio

  • First, ensure that you have the latest Visual Studio installed and up-to-date.
  • Install CMake or update it if you have not already. Be sure to add it to PATH when the installer asks for it.
  • (Optional, required for tests) Download Qt and install it.
  • 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 https://github.com/OSSIA/libossia
  • Run a Visual Studio command prompt (for instance VS2015 x86 Native Tools).
  • Find and save where the various libraries you installed are. For instance:
   set QTDIR=c:\Qt\5.7\msvc2015 # Should contain "bin", "doc", "include"...
   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 -DCMAKE_PREFIX_PATH="%QTDIR%/lib/cmake/Qt5" "%LIBOSSIA_DIR%"

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

Note: The next iteration of Visual Studio (2017) will have a built-in CMake support so this command-line step won't be necessary.

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 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:

Setup

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.)

  • First, if you have OS X 10.12, ensure that you have the latest Xcode 8 installed and up-to-date. If you're not on 10.12 for some reasons, you can still build libossia yourself but you need to use GCC. You can install it from brew (brew install gcc) and then configure build to use it instead of Apple Clang.
  • Install Homebrew
  • In a terminal, run :
brew update
brew install wget cmake

You can then clone the libossia repository:

git clone 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 -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 7/Package/ to load ossia at Max startup :

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

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 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=$(python-config --prefix)/lib/libpython3.6.dylib -DPYTHON_EXECUTABLE=/usr/local/bin/python3 -DPYTHON_INCLUDE_DIR=$(python-config --prefix)/include/python3.6

  • Python 2.7 & 3.6

make -j 4

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

You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.
Press h to open a hovercard with more details.