This guide provides instructions for installing and compiling the liboqs and liboqs-python libraries on Windows and Raspberry Pi.
Before starting, ensure you have the following installed:
- Python 3.10+ (Ensure "Add Python to PATH" was checked during installation)
- Git
We need a C++ compiler and CMake.
- Download Build Tools for Visual Studio 2026 (
vs_BuildTools.exe) from the official Microsoft download page (scroll to the bottom, under "All Downloads" -> "Tools for Visual Studio").- Recommended: Click this link to download the Build Tools: https://aka.ms/vs/stable/vs_BuildTools.exe
- Visual Studio Download: https://visualstudio.microsoft.com/downloads
- Run the installer (
vs_BuildTools.exe). - Under the Workloads tab, check ONLY one option:
- Desktop development with C++
- On the right-side Installation details panel, uncheck unnecessary components to save space, but ensure these three are checked:
- MSVC v14x - VS C++ x64/x86 build tools
- Windows 11 SDK
- C++ CMake tools for Windows
- Click Install. You can close the installer once it finishes.
Python requires a dynamic library (.dll) to interact with C code. We must compile liboqs specifically to generate this file.
- Click the Windows Start menu, search for "Developer Command Prompt for VS", right-click it, and select Run as administrator.
- The prompt defaults to
C:\Windows\System32. Do not clone code here. Move to a safe root directory:cd /d C:\mkdir devcd dev - Run the following commands sequentially to clone and compile:
- Clone the 0.14.0 version:
git clone --branch 0.14.0 https://github.com/open-quantum-safe/liboqs.git
cd liboqs- Configure CMake:
cmake -S . -B build -DBUILD_SHARED_LIBS=ON
- Build the project:
cmake --build build --config Release
- Install to the default Windows system directory:
The compiled files are now located incmake --install build
C:\Program Files (x86)\liboqs.
Python needs to know where the compiled .dll file is located.
- Open Windows Search and type "Edit the system environment variables", then hit Enter.
- Click the Environment Variables button at the bottom right.
- Under the System variables section (the bottom list), find and double-click the variable named
Path. - Click New and paste the exact path to the
binfolder:C:\Program Files (x86)\liboqs\bin - Click OK on all three windows to save the settings.
For the new environment variables to take effect, you must completely close any open terminals or IDEs before proceeding.
- Open a fresh, standard Command Prompt or your Python virtual environment.
- Install the Python wrapper:
pip install liboqs-python
Create a test script (e.g., test_pqc.py) and run the following code to ensure the Python wrapper is successfully communicating with the underlying C library.
import oqs
print("liboqs version:", oqs.oqs_version())
print("liboqs-python version:", oqs.oqs_python_version())
print("KEM supported in liboqs:")
print(oqs.get_supported_kem_mechanisms()[:3])This step ensures we have the correct build tools (cmake, ninja) and the essential development libraries required for cryptographic algorithms (OpenSSL headers).
- Update the system package list
sudo apt updatesudo apt upgrade -y- Install build tools and dependencies
sudo apt install -y build-essential cmake ninja-build libssl-dev git python3-pip python3-venvliboqs-python is just a wrapper; it heavily relies on the .so dynamic library existing in the system. We must compile the C library correctly first.
- Return to the home directory
cd ~- Clone the specific 0.14.0 version source code
git clone --branch 0.14.0 https://github.com/open-quantum-safe/liboqs.gitcd liboqs- Create a build directory
mkdir build && cd build- Configure the project using CMake
cmake -GNinja -DBUILD_SHARED_LIBS=ON -DCMAKE_INSTALL_PREFIX=/usr/local ..- Compile and install to the system path
ninjasudo ninja install- Refresh the system's shared library cache
sudo ldconfigVerification: Run ls -l /usr/local/lib/liboqs* to ensure you can see liboqs.so.0.14.0.
To avoid polluting the Raspberry Pi's system-level Python environment, we use a virtual environment for isolation.
- Return to the home directory
cd ~- Create a virtual environment named oqs_env
python3 -m venv oqs_env- Activate the virtual environment (Once successful, your command line prefix will show "(oqs_env)")
source oqs_env/bin/activate- Update base packages (Optional but recommended)
pip install --upgrade pip setuptoolsYou must compile and install from the local source code while the virtual environment is activated. This ensures it perfectly binds to the 0.14.0 C library you just compiled.
- Ensure the virtual environment is ACTIVATED
source oqs_env/bin/activate- Return to the home directory
cd ~- Clone the Python wrapper source code
git clone https://github.com/open-quantum-safe/liboqs-python.gitcd liboqs-python- Compile and install locally
pip install . --no-cache-dirRun the following Python one-liner directly in the terminal to test your installation:
python3 -c "import oqs; print('\n Installation Successful!\nCurrent liboqs and liboqs-python version:', oqs.oqs_version(), oqs.oqs_python_version()); print('Supported KEM algorithms:', oqs.get_enabled_kem_mechanisms()[:3])"Updated on April 20, 2026