C / C++

First clone the SCS repo from GitHub

git clone https://github.com/cvxgrp/scs.git

CMake

Thanks to the CMake buildsystem SCS can be easily compiled and linked to other CMake projects. To use the cmake buld system please run the following commands:

cd scs
mkdir build
cd build
cmake -DCMAKE_INSTALL_PREFIX:PATH=<custom-folder> ../
make
make install

You may also want to compile the tests. In this case when you configure the project, please call the following command

cmake -DCMAKE_INSTALL_PREFIX:PATH=<custom-folder> -DBUILD_TESTING=ON ../
make
ctest

Some compile flags can be overridden using the command line, for example we can compile the library (and headers) to use 64 bit integers using:

cmake -DCMAKE_INSTALL_PREFIX:PATH=<custom-folder> -DDLONG=ON ../
make

By default the build-system will compile the library as shared. If you want to compile it as static, please call the following command when you configure the project

cmake -DCMAKE_INSTALL_PREFIX:PATH=<custom-folder> -BUILD_SHARED_LIBS=OFF ../
make

The CMake build-system exports two CMake targets called scs::scsdir and scs::scsindir as well as a header file scs.h that defines the API.

If MKL is installed in your system and the MKLROOT environment variable is set, then additionally CMake will build and install the MKL Pardiso linear solver with target scs::scsmkl. (Note that the choice of MKL compiler flags might not be right for your system and may need to be modified).

The libraries can be imported using the find_package CMake command and used by calling target_link_libraries as in the following example:

cmake_minimum_required(VERSION 3.0)
project(myproject)
find_package(scs REQUIRED)
add_executable(example example.cpp)

# To use the direct method
target_link_libraries(example scs::scsdir)

# To use the indirect method
target_link_libraries(example scs::scsindir)

# To use the MKL Pardiso direct method
target_link_libraries(example scs::scsmkl)

Makefile

Alternatively you can use the Makefile and manage the libraries and header files yourself. The public header files are scs.h and scs_types.h.

cd scs
make

To compile and run the tests execute

make test
out/run_tests_direct
out/run_tests_indirect

If make completes successfully, it will produce two static library files, libscsdir.a, libscsindir.a, and two dynamic library files libscsdir.ext, libscsindir.ext (where .ext extension is platform dependent) in the out folder.

If MKL is installed in your system and the MKLROOT environment variable is set, then you can compile and test the MKL Pardiso version of SCS using:

make mkl
out/run_tests_mkl

This will produce static library libscsmkl.a and dynamic library libscsmkl.ext (again .ext is platform dependent) in the out folder. (Note that the choice of MKL compiler flags might not be right for your system and may need to be modified).

If you have a GPU and have CUDA installed, you can also execute make gpu to compile SCS to run on the GPU which will create additional libraries and demo binaries in the out folder corresponding to the GPU version. Note that the GPU (usually) requires 32 bit ints, which can be enforced by compiling with DLONG=0.

make gpu DLONG=0
out/run_tests_gpu_indirect

To use the libraries in your own source code, compile your code with the linker option -L(PATH_TO_SCS_LIBS) and -lscsdir or -lscsindir (as needed). The API and required data structures are defined in the file include/scs.h and documented here.