Skip to content

Platform specific notes for building liboqs

Michael Baentsch edited this page Feb 10, 2023 · 14 revisions

Linux

After installing the base prerequisites older computing hardware may require the installation of gcc-multilib, e.g. by running apt install gcc-multilib.

Benchmarking on ARMv8

When compiling on ARMv8, by default benchmarking in liboqs will use clock_gettime, which offers lower temporal accuracy. To get the more accurate cycle count, ARMv8's Performance Monitoring Unit (PMU) can be used via the OQS_SPEED_USE_ARM_PMU option. Access to the PMU from user mode must be enabled via a kernel module. Instructions for this can be found here.

OpenBSD

Install the dependencies using pkg_add:

pkg_add cmake ninja
pkg_add -r python
pip3 install pytest pytest-xdist

Then proceed with the remaining instructions here.

OSX

Due to the large number of algorithms supported by liboqs it is known that on some OSX installations linking may fail with the error message

/Applications/Xcode-11.3.1.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc: Argument list too long

All suggestions for resolving this limitation would be thankfully received, ideally by PR to the project. Until it is resolved, a possible solution is to not enable all algorithms. This can be facilitated by suitably setting to OFF select algorithms using OQS_ENABLE_ build flags.

Building on Windows

Using MSVC

  1. Install supported MS Visual Studio 19 and required cmake.

  2. Continue according to paragraph 2 of the quick-start instructions for building liboqs. To use msbuild do not specify ninja as a build tool, i.e., use cmake .. for generating MSVC build targets. Execute them as usual, e.g. using msbuild ALL_BUILD.vcxproj instead of running ninja.

Using MSYS2 and Mingw

  1. Install required components:

64 bit

Using the mingw64.exe shell:

pacman -S git \
          mingw-w64-x86_64-cmake \
          mingw-w64-x86_64-ninja \
          mingw-w64-x86_64-python-pytest \
          mingw-w64-x86_64-python-pytest-xdist \
          mingw-w64-x86_64-toolchain

32 bit

Using mingw32.exe shell:

pacman -S git \
          mingw-w64-i686-cmake \
          mingw-w64-i686-ninja \
          mingw-w64-i686-python-pytest \
          mingw-w64-i686-python-pytest-xdist \
          mingw-w64-i686-toolchain
  1. Continue according to paragraph 2 of the quick-start instructions for building liboqs.

Using cygwin

  1. Install required components using cygwin setup: Be sure to select at least git, gcc, ninja, cmake, python3. Also install libssl-devel if building using OpenSSL (default liboqs build option OQS_USE_OPENSSL). For testing, be sure to install python components pytest, pytest-xdist, and psutils, using pip, e.g. running the command pip install pytest pytest-xdist psutil.

  2. Continue according to paragraph 2 of the quick-start instructions for building liboqs. When creating cmake Makefiles consider to disable algorithms not properly supported under Windows, e.g., using the command cmake -GNinja -DOQS_ENABLE_KEM_BIKE=OFF ...

Cross-compiling

Cross-compiling on Linux for ARM

Binaries for ARM can be cross-compiled on Linux. In order to do so, you need to supply CMake with an appropriate toolchain file.

For example, to cross compile for a Raspberry Pi on an x86-64 Ubuntu Bionic machine:

apt install gcc-8-arm-linux-gnueabihf
mkdir build && cd build
cmake -GNinja -DCMAKE_TOOLCHAIN_FILE=../.CMake/toolchain_rasppi.cmake -DOQS_USE_OPENSSL=OFF ..
ninja

Cross-compiling on Debian/Ubuntu Linux for Windows

Binaries for Windows AMD64 can be cross-compiled on Linux. In order to do so, you need to supply CMake with an appropriate toolchain file. The following example shows how to use the toolchain for Windows AMD64 compilation. The subsequent section shows how to build using a different approach.

apt install gcc-mingw-w64
mkdir build && cd build
cmake -GNinja -DCMAKE_TOOLCHAIN_FILE=../.CMake/toolchain_windows-amd64.cmake ..
ninja

Cross-building a Windows DLL

To compile for Windows AMD64 from Ubuntu Bionic and create a liboqs.dll file

apt install cmake gcc gcc-mingw-w64 ninja-build
git clone https://github.com/open-quantum-safe/liboqs
cd liboqs
mkdir build && cd build
cmake -GNinja -DCMAKE_TOOLCHAIN_FILE=../.CMake/toolchain_windows-amd64.cmake -DOQS_DIST_BUILD=ON -DBUILD_SHARED_LIBS=ON ..
ninja

This will generate a bin/liboqs.dll file in the build directory that you will need to copy to Windows. You should configure it to be available via the PATH environment variable.

Notes

  1. Cross-compiled code does not activate all CPU feature optimization flags. If such optimized code is required, using native Windows tooling is recommended.

Cross-compiling on Arch Linux for Windows

  1. You need to enable the ownstuff repository.

  2. Install required components:

pacman -S git \
          mingw-w64-cmake \
          mingw-w64-openssl \
          mingw-w64-toolchain \
          ninja
  1. Get the source:
git clone -b master https://github.com/open-quantum-safe/liboqs.git
cd liboqs
  1. Build:

64 bit

mkdir build && cd build
x86_64-w64-mingw32-cmake .. -GNinja
ninja

32 bit

mkdir build && cd build
i686-w64-mingw32-cmake .. -GNinja
ninja