inst/HiGHS/cmake/README.md

HiGHS CMake Build Instructions

| OS | C++ | Fortran | Python | CSharp Example | .NET | |:-------- | :---: | :------: | :----: | :----: | :----: | | Linux | Status | Status | Status | (1) | Status | | MacOS | Status | Status | Status | (1) |Status | | Windows | Status | (2) | Status | Status | Status |

(1) CMake C# is currently only supported for Microsoft Visual Studio 11 2012 and later. You can still build and run the HiGHS C# nuget package on Linux and MacOS with dotnet, see the workflows in the .NET column. It is only the CSharp example build with CMake that is not supported for Unix generators.

(2) Not tested yet.

Contents

Introduction

HiGHS can be built from source using CMake: http://www.cmake.org/. CMake works by generating native Makefiles or build projects that can be used in the compiler environment of your choice.

HiGHS can be built as a standalone project or it could be incorporated into an existing CMake project.

Requirement

You'll need:

Supported compilers

Here is a list of the supported compilers:

Build

To build the C++ library and executable run

cd HiGHS
cmake -S. -B build 
cmake --build build --parallel

This generates HiGHS in the build directory and creates the executable build/bin/highs, or build/bin/Release/highs.exe on Windows. To perform a quick test to see whether the compilation was successful, run ctest from within the build folder.

ctest 

On Windows, the configuration type must be specified:

ctest -C Release

Install

The default installation location may need administrative permissions. To install, after building and testing, run

cmake --install build 

form the root directory.

To install in a specified installation directory run CMake with the CMAKE_INSTALL_PREFIX flag set:

cmake -S. -B build -DCMAKE_INSTALL_PREFIX=/path/to/highs_install 
cmake --build build --parallel
cmake --install build

Windows

By default, CMake builds the debug version of the binaries. These are generated in a directory Debug. To build a release version, add the option --config Release

    cmake -S . -B build
    cmake --build build --config Release

It is also possible to specify a specific Visual studio version to build with:

    cmake -G "Visual Studio 17 2022" -S . -B build
    cmake --build build

When building under Windows, some extra options are available. One is building a 32 bit version or a 64 bit version. The default build is 64 bit. To build 32 bit, the following commands can be used from the HiGHS/ directory:

    cmake -A Win32 -S . -B buildWin32
    cmake --build buildWin32

Another thing specific for windows is the calling convention, particularly important for the HiGHS dynamic library (dll). The default calling convention in windows is cdecl calling convention, however, dlls are most often compiled with stdcall. Most applications which expect stdcall, can't access dlls with cdecl and vice versa. To change the default calling convention from cdecl to stdcall the following option can be added

    cmake -DSTDCALL=ON -S . -B build
    cmake --build build

CMake Options

There are several options that can be passed to CMake to modify how the code is built. To set these options and parameters, use -D<Parameter_name>=<value>.

All CMake options are passed at configure time, i.e., by running cmake -S. -B<your_chosen_build_directory> -DOPTION_ONE=ON -DOPTION_TWO=OFF ... before running cmake --build <your_chosen_build_directory>

For example, to generate build files in a new subdirectory called 'build', run:

cmake -S. -Bbuild 

and then build with:

cmake --build build

Following is a list of available options: | CMake Option | Default Value | Note | |:-------------|:--------------|:-----| | CMAKE_BUILD_TYPE | Release | see CMake documentation here | | BUILD_SHARED_LIBS | ON(*) | Build shared libraries (.so or .dyld). * OFF by default on Windows | | BUILD_CXX | ON | Build C++ | | FORTRAN | OFF | Build Fortran interface | | CSHARP | OFF | Build CSharp wrapper | | BUILD_DOTNET | OFF | Build .Net package | | PYTHON_BUILD_SETUP | OFF | Build Python bindings. Called at pip install from pyproject.toml | | ZLIB | ON | Use ZLIB if available | | ALL_TESTS | OFF | Run unit tests and extended instance test set |



Try the highs package in your browser

Any scripts or data that you put into this service are public.

highs documentation built on April 4, 2025, 3:23 a.m.