4 Installation

In this section we discuss how to install and setup the MOSEK Fusion API for C++.

Important

Before running this MOSEK interface please make sure that you:

  • Installed MOSEK correctly. Some operating systems require extra steps. See the Installation guide for instructions and common troubleshooting tips.

  • Set up a license. See the Licensing guide for instructions.

Compatibility

The Fusion API for C++ is compatible with the following compiler tool chains:

Platform

Supported compiler

Framework

Linux 64 bit x86

gcc (≥ 4.8)

glibc (≥ 2.2)

Mac OS 64 bit

Xcode (≥ 5)

MAC OS SDK (≥ 10.7)

Windows 64 bit

Visual Studio (≥ 2015)

Windows 8.1 SDK

Linux ARM64

gcc (≥ 9.2)

glibc (≥ 2.20)

In many cases older versions can also be used. In particular Fusion API for C++ requires a C++11 compliant compiler.

Locating files in the MOSEK Optimization Suite

The relevant files of the Fusion API for C++ are organized as reported in Table 4.1.

Table 4.1 Relevant files for the Fusion API for C++.

Relative Path

Description

Label

<MSKHOME>/mosek/9.3/tools/platform/<PLATFORM>/h

Header files

<HEADERDIR>

<MSKHOME>/mosek/9.3/tools/platform/<PLATFORM>/src/fusion_cxx

Source files

<SRCDIR>

<MSKHOME>/mosek/9.3/tools/platform/<PLATFORM>/bin

Shared libraries

<LIBDIR>

<MSKHOME>/mosek/9.3/tools/examples/fusion/cxx

Examples

<EXDIR>

<MSKHOME>/mosek/9.3/tools/examples/fusion/data

Additional data

<MISCDIR>

where

  • <MSKHOME> is the folder in which the MOSEK Optimization Suite has been installed,

  • <PLATFORM> is the actual platform among those supported by MOSEK, i.e. win64x86, linux64x86, osx64x86 or linuxaarch64.

Manual compilation (all platforms)

This step is compulsory on Linux and Mac OS. The implementation of Fusion is distributed as C++ source code in <MSKHOME>/mosek/9.3/tools/platform/<PLATFORM>/src/fusion_cxx. It can be compiled as follows:

  1. Go to <MSKHOME>/mosek/9.3/tools/platform/<PLATFORM>/src/fusion_cxx

  2. Run make install (Linux, Mac OS) or nmake install (Windows).

  3. If no error occurs, then the Fusion C++ API has been successfully compiled and the corresponding libraries have been copied to <MSKHOME>/mosek/9.3/tools/platform/<PLATFORM>/bin.

Using a pre-compiled library (only Windows)

On Windows 64bit the users can skip the compilation step and use a pre-compiled library fusion64_9_3.lib available in <MSKHOME>/mosek/9.3/tools/platform/<PLATFORM>/bin.

Setting up paths and linking

To compile and link a C++ application using Fusion, the user must set paths to header files, compiled Fusion libraries, and run-time dependencies must be resolved. Details vary depending on the operating system and compiler. See the Makefile included in the distribution under <MSKHOME>/mosek/9.3/tools/examples/fusion/cxx for a working example. Typically:

  • Linux 64bit x86:

    g++ -std=c++11 file.cc -o file -I<HEADERDIR> -L<LIBDIR> -Wl,-rpath-link,<LIBDIR> -Wl,-rpath=<LIBDIR> -lmosek64 -lfusion64

    The shared libraries libmosek64.so.9.3, libfusion64.so.9.3 must be available at runtime.

  • Mac OS:

    clang++ -std=c++11 -stdlib=libc++ file.cc -o file -I<HEADERDIR> -L<LIBDIR> -Wl,-headerpad,128 -lmosek64 -lfusion64
    install_name_tool -change libmosek64.9.3.dylib <LIBDIR>/libmosek64.9.3.dylib file
    install_name_tool -change libfusion64.9.3.dylib <LIBDIR>/libfusion64.9.3.dylib file

    The shared libraries libmosek64.9.3.dylib, libfusion64.9.3.dylib must be available at runtime.

  • Windows:

    cl /I<HEADERDIR> file.cc /link /LIBPATH:<LIBDIR> fusion64_9_3.lib mosek64_9_3.lib

    The shared library mosek64_9_3.dll must be available at runtime.

  • Linux ARM64:

    g++ -std=c++11 file.cc -o file -I<HEADERDIR> -L<LIBDIR> -Wl,-rpath-link,<LIBDIR> -Wl,-rpath=<LIBDIR> -lpthread -lmosek64 -lfusion64

    The shared libraries libmosek64.so.9.3, libfusion64.so.9.3 must be available at runtime.

Importing the source code

Alternatively, the Fusion source code from <MSKHOME>/mosek/9.3/tools/platform/<PLATFORM>/src/fusion_cxx can be imported into any other project, or compiled into a stand-alone library by the user. This is especially useful if non-standard compiler options should be used.

4.1 Testing the installation and compiling examples

The example directory <MSKHOME>/mosek/9.3/tools/examples/fusion/cxx contains a makefile for use with make (Linux, Mac OS) or nmake (Windows).

To build the examples, open a shell (Linux, Mac OS) or a Developer Command Prompt and go to <EXDIR>. To compile all examples run the one of the commands

make all

nmake all

depending on the operating system. To build only a single example, for instance lo1.cc, use one of the following:

make lo1

nmake lo1.exe

4.2 Creating a Visual Studio Project

The following walk-through describes how to set up a 64bit Fusion project with Microsoft Visual Studio 2019. Similar steps should be followed with other tools and setup configurations.

  • Create a Visual C++ project or open an existing project in Visual Studio.

  • Go to ProjectProperties.

  • In the selection box Configuration: select Release and in Platform: select x64.

  • Go to Configuration Manager and set Active solution configuration to Release and Active solution platform to x64.

  • Under Configuration PropertiesC/C++GeneralAdditional Include Directories add the full path to <HEADERDIR>.

  • Under Configuration PropertiesC/C++Code GenerationRuntime library select Multi-threaded (/MT).

  • Under Configuration PropertiesLinkerInputAdditional Dependencies add the full paths to the files mosek64_9_3.lib and fusion64_9_3.lib.

  • To ensure that mosek64_9_3.dll is available in the DLL search path during execution, set Configuration PropertiesDebuggingEnvironment to PATH=%PATH%;<LIBDIR>.

4.3 Troubleshooting

error LNK2038

The distributed Fusion library is built in StaticRelease mode. Attempts to link it with an application built in a different mode, like DynamicDebug mode, will result in errors such as:

error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MT_StaticRelease' doesn't match value 'MDd_DynamicDebug' in lo1.obj

However, if you must use different configurations for your project, then you may import the Fusion source code from <MSKHOME>/mosek/9.3/tools/platform/<PLATFORM>/src/fusion_cxx directly into your project and compile within the project with whatever compiler and linker settings you require.