Building from Source¶
Developer guide for building POGS from source.
Prerequisites¶
Required¶
- C++ compiler with C++20 support:
- GCC 10+
- Clang 13+
- AppleClang 13+
- MSVC 19.29+
- CMake 3.20 or higher
- BLAS/LAPACK libraries
Optional¶
- CUDA Toolkit 11.0+ (for GPU support)
- Python 3.7+ (for Python interface)
- Doxygen (for API documentation)
Quick Start¶
# Clone repository
git clone https://github.com/foges/pogs.git
cd pogs
# Configure (CPU-only, Release build)
cmake -B build \
-DCMAKE_BUILD_TYPE=Release \
-DPOGS_BUILD_GPU=OFF \
-DPOGS_BUILD_TESTS=ON \
-DPOGS_BUILD_EXAMPLES=ON
# Build
cmake --build build --config Release -j4
# Run tests
cd build
ctest --output-on-failure
# Install (optional)
sudo cmake --install build
Build Options¶
| Option | Default | Description |
|---|---|---|
CMAKE_BUILD_TYPE |
Release |
Build type (Release, Debug, RelWithDebInfo) |
POGS_BUILD_GPU |
OFF |
Build GPU support with CUDA |
POGS_BUILD_TESTS |
ON |
Build test suite |
POGS_BUILD_EXAMPLES |
ON |
Build examples |
CMAKE_INSTALL_PREFIX |
/usr/local |
Installation directory |
Example Configurations¶
Debug build:
With GPU support:
Custom install location:
Platform-Specific Instructions¶
macOS¶
macOS includes the Accelerate framework:
# Install CMake
brew install cmake
# Build
cmake -B build -DCMAKE_BUILD_TYPE=Release -DPOGS_BUILD_GPU=OFF
cmake --build build
Xcode:
Linux (Ubuntu/Debian)¶
# Install dependencies
sudo apt-get update
sudo apt-get install \
cmake \
g++ \
libopenblas-dev \
liblapack-dev
# Build
cmake -B build -DCMAKE_BUILD_TYPE=Release
cmake --build build
Linux (Fedora/RHEL)¶
# Install dependencies
sudo dnf install \
cmake \
gcc-c++ \
openblas-devel \
lapack-devel
# Build
cmake -B build -DCMAKE_BUILD_TYPE=Release
cmake --build build
Windows (Visual Studio)¶
# Configure
cmake -B build -G "Visual Studio 17 2022" -A x64
# Build
cmake --build build --config Release
# Install
cmake --install build --config Release
Note: You'll need to provide BLAS/LAPACK (e.g., Intel MKL or OpenBLAS).
GPU Build¶
Prerequisites¶
- CUDA Toolkit 11.0 or higher
- NVIDIA GPU with compute capability 3.5+
Configuration¶
cmake -B build \
-DCMAKE_BUILD_TYPE=Release \
-DPOGS_BUILD_GPU=ON \
-DCUDA_TOOLKIT_ROOT_DIR=/usr/local/cuda
Troubleshooting¶
If CMake can't find CUDA:
Testing¶
Run All Tests¶
Run Specific Tests¶
Expected Output¶
Test project /path/to/pogs/build
Start 1: test_cone
1/2 Test #1: test_cone ........................ Passed 0.15 sec
Start 2: test_sdp
2/2 Test #2: test_sdp ......................... Passed 0.08 sec
100% tests passed, 0 tests failed out of 2
Installation¶
System-Wide Install¶
Installs to /usr/local by default:
- Headers: /usr/local/include/pogs/
- Library: /usr/local/lib/libpogs_cpu.a
- CMake config: /usr/local/lib/cmake/POGS/
User Install¶
Then add to your environment:
export CMAKE_PREFIX_PATH=$HOME/local:$CMAKE_PREFIX_PATH
export LD_LIBRARY_PATH=$HOME/local/lib:$LD_LIBRARY_PATH
Using POGS in Your Project¶
CMake Integration¶
find_package(POGS REQUIRED)
add_executable(myapp main.cpp)
target_link_libraries(myapp PRIVATE pogs::cpu)
Manual Compilation¶
g++ -std=c++20 -O3 myapp.cpp \
-I/usr/local/include \
-L/usr/local/lib \
-lpogs_cpu \
-llapack -lblas \
-o myapp
macOS:
g++ -std=c++20 -O3 myapp.cpp \
-I/usr/local/include \
-L/usr/local/lib \
-lpogs_cpu \
-framework Accelerate \
-o myapp
Development Build¶
For active development:
# Debug build with all warnings
cmake -B build \
-DCMAKE_BUILD_TYPE=Debug \
-DCMAKE_CXX_FLAGS="-Wall -Wextra -Wpedantic"
# Build and run tests frequently
cmake --build build && cd build && ctest
Code Formatting¶
Format code before committing:
Troubleshooting¶
CMake Can't Find BLAS/LAPACK¶
macOS:
Linux:
cmake -B build \
-DBLAS_LIBRARIES="/usr/lib/x86_64-linux-gnu/libopenblas.so" \
-DLAPACK_LIBRARIES="/usr/lib/x86_64-linux-gnu/liblapack.so"
Compiler Not C++20 Compatible¶
# Check version
g++ --version
# Specify compiler explicitly
cmake -B build -DCMAKE_CXX_COMPILER=g++-11
CUDA Not Found¶
Clean Build¶
# Remove build directory
rm -rf build
# Reconfigure and rebuild
cmake -B build -DCMAKE_BUILD_TYPE=Release
cmake --build build
See Also¶
- Architecture - Code structure
- Contributing - How to contribute
- Installation Guide - User installation