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 gcc (≥ 4.8) glibc (≥ 2.2)
Mac OS 64 bit Xcode (≥ 5) MAC OS SDK (≥ 10.7)
Windows Visual Studio (≥ 2015)  

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

Locating Files

The files in Fusion API for C++ are organized as reported in Table 1.

Table 1 Relevant files for the Fusion API for C++.
Relative Path Description Label
<MSKHOME>/mosek/8/tools/platform/<PLATFORM>/h Header files <HEADERDIR>
<MSKHOME>/mosek/8/tools/platform/<PLATFORM>/src/fusion_cxx Source files <SRCDIR>
<MSKHOME>/mosek/8/tools/platform/<PLATFORM>/bin Shared libraries <LIBDIR>
<MSKHOME>/mosek/8/tools/examples/fusion/cxx Examples <EXDIR>
<MSKHOME>/mosek/8/tools/examples/fusion/data Additional data <MISCDIR>

where

  • <MSKHOME> is the folder in which the MOSEK package 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/8/tools/platform/<PLATFORM>/src/fusion_cxx. It can be compiled as follows:

  1. Go to <MSKHOME>/mosek/8/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/8/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_8_1.lib available in <MSKHOME>/mosek/8/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/8/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.8.1, libfusion64.so.8.1 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.8.1.dylib <LIBDIR>/libmosek64.8.1.dylib file
    install_name_tool -change libfusion64.8.1.dylib <LIBDIR>/libfusion64.8.1.dylib file
    

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

  • Windows:

    cl /I<HEADERDIR> file.cc /link /LIBPATH:<LIBDIR> fusion64_8_1.lib mosek64_8_1.lib
    

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

Importing the source code

Alternatively, the Fusion source code from <MSKHOME>/mosek/8/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/8/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 2017. With another tools and setup configurations the steps should be similar.

  • Create a Visual C++ project or open an existing project in Visual Studio.
  • Go to ProjectProperties.
  • In the selection box Configuration: select All Configurations.
  • If necessary go to Configuration Manager and change Active Solution Platform to x64.
  • Under Configuration PropertiesC/C++GeneralAdditional Include Directories add the full path to <HEADERDIR>.
  • Under Configuration PropertiesLinkerInputAdditional Dependencies add the full paths to the files mosek64_8_1.lib and fusion64_8_1.lib.
  • Make sure that mosek64_8_1.dll is available in the DLL search path when executing the compiled code.