Build from sources

Install GCC and CMake

The main compilation directives are specified using

Linux

Both gcc and cmake commands are already installed by default.

Mac OS

Install Xcode and command line tools

  1. Install the latest release of Xcode.

  2. Install the command line tools by executing from the terminal

    xcode-select --install
    

Install CMake via Homebrew

  1. Install Homebrew and update its packages to the latest version.

  2. Install cmake by executing

    brew install cmake
    

Windows

  1. Install TDM-GCC 32bit or 64bit depending on your platform.
  2. Install the latest binaries of CMake.
  3. Make sure you have the privileges to create symbolic links. See the git wiki for more details.

Build the binaries

Run the following commands from the terminal

  1. Clone the repository, create build directory and change directory

    • On Linux and Mac OS run

      git clone https://github.com/oxfordcontrol/osqp
      cd osqp
      mkdir build
      cd build
      
    • On Windows run

      git clone -c core.symlinks=true https://github.com/oxfordcontrol/osqp
      cd osqp
      mkdir build
      cd build
      
  2. Create Makefiles

    • In Linux and Mac OS run

      cmake -G "Unix Makefiles" ..
      
    • In Windows run

      cmake -G "MinGW Makefiles" ..
      
  3. Compile OSQP

    cmake --build .
    

Thanks to CMake, it is possible to create projects for a wide variety of IDEs; see here for more details. For example, to create a project for Visual Studio 14 2015, it is just necessary to run

cmake -G "Visual Studio 14 2015" ..

The compilation will generate the demo osqp_demo and the unittests osqp_tester executables. In the case of Unix or MinGW Makefiles option they are located in the build/out/ directory. Run them to check that the compilation was correct.

Once the sources are built, the generated static build/out/libosqpstatic.a and shared build/out/libosqp.ext libraries can be used to interface any C/C++ software to OSQP (see CC++ interface installation).