C/C++

Build binaries

Building binaries from source requires installation of cmake and a C compiler such as clang or gcc.

Run the following to get the libqoco.so shared object file.

  1. Clone the repository and change directory.
    git clone https://github.com/qoco-org/qoco
    cd qoco
    
  2. Make build directory and change directory.
    mkdir build
    cd build
    
  3. Compile sources.
    cmake .. && make
    

    You should now see two binaries: libqoco.so which is the qoco library, and qoco_demo which solves a sample SOCP. To build unit tests, add -DENABLE_TESTING:BOOL=True to the cmake call. Note that when running unit tests, it is required to have cvxpy installed.

CUDA Backend

To build with GPU acceleration, pass -DQOCO_ALGEBRA_BACKEND=cuda to CMake. This requires the CUDA Toolkit to be installed and nvcc to be on your PATH.

cmake .. -DQOCO_ALGEBRA_BACKEND=cuda && make

Runtime requirements: The CUDA backend loads cuDSS dynamically at runtime via dlopen. cuDSS does not need to be present at build time, but it must be installed and findable on your system’s library path (LD_LIBRARY_PATH on Linux, DYLD_LIBRARY_PATH on macOS) before running any program linked against libqoco.so.

Use with CMake

To use in a CMake project add the following to your CMakeLists.txt file

add_subdirectory(QOCO_DIRECTORY)
target_link_libraries(yourExecutable qoco)

Where QOCO_DIRECTORY is the location where qoco is cloned. To use the CUDA backend in your project, pass -DQOCO_ALGEBRA_BACKEND=cuda when invoking CMake.