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.5)

glibc (≥ 2.17)

Linux 64 bit ARM

clang (≥ 10)

glibc (≥ 2.29)

macOS 64 bit x86

Xcode (≥ 11)

MAC OS SDK (≥ 10.15)

macOS 64 bit ARM

Xcode (≥ 12)

MAC OS SDK (≥ 11)

Windows 64 bit x86

Visual Studio (≥ 2017)

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/10.1/tools/platform/<PLATFORM>/h

Header files

<HEADERDIR>

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

Source files

<SRCDIR>

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

Shared libraries

<LIBDIR>

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

Examples

<EXDIR>

<MSKHOME>/mosek/10.1/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 or osx64x86.

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/10.1/tools/platform/<PLATFORM>/src/fusion_cxx. It can be compiled as follows:

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

  2. Run make install (Linux, macOS) 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/10.1/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_10_1.lib available in <MSKHOME>/mosek/10.1/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/10.1/tools/examples/fusion/cxx for a working example. Typically:

  • Linux:

    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.10.1, libfusion64.so.10.1 must be available at runtime.

  • macOS:

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

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

  • Windows:

    cl /I<HEADERDIR> file.cc /link /LIBPATH:<LIBDIR> fusion64_10_1.lib mosek64_10_1.lib

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

Importing the source code

Alternatively, the Fusion source code from <MSKHOME>/mosek/10.1/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/10.1/tools/examples/fusion/cxx contains a makefile for use with make (Linux, macOS) or nmake (Windows).

To build the examples, open a shell (Linux, macOS) 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 (/MD).

  • Under Configuration PropertiesLinkerInputAdditional Dependencies add the full paths to the files mosek64_10_1.lib and fusion64_10_1.lib.

  • To ensure that mosek64_10_1.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 /MD mode. Attempts to link it with an application built in a different mode, like /MT, /MDd, /MTd, will result in errors such as:

error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MD_DynamicRelease' 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/10.1/tools/platform/<PLATFORM>/src/fusion_cxx directly into your project and compile within the project with whatever compiler and linker settings you require.