4 Installation

In this section we discuss how to install and setup the MOSEK Rmosek package.


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.


The Rmosek package can be used with R version at least 3.6.

Locating files in the MOSEK Optimization Suite

The relevant files for the Rmosek package are organized as reported in Table 4.1.

Table 4.1 Relevant files for the Rmosek package.

Relative Path




Rmosek install files






Additional data



  • <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. win32x86, win64x86, linux64x86 or osx64x86.

4.1 System requirements

There are no pre-compiled binary versions of the Rmosek package available, so the system must be able compile C++ source code and have access to a few command line tools. The summary of relevance to the Rmosek package given below is based on the official guide, R Installation and Administration, for installing packages in source form.


  • Download Rtools (not an R package). You will need to install the R toolset, the Cygwin DLLs, and the toolchain.

  • Make sure you have mosek and the executables of Rtools on the PATH environment variable.


  • Make sure you have Xcode installed.


  • On Ubuntu (and Debian) you may install the r-base-dev package.

4.2 Installation

To install the Rmosek package you may run the install.rmosek function of the script <RMOSEKDIR>/builder.R. This is a wrapper around the install.packages function with recommended default argument values (e.g., to a compatible MOSEK repository), cross-platform support of configurations variables, and helpers to resolve Rtools on Windows. As example, if called with no arguments, it will attempt an autoconfigured installation:


You can inspect the autoconfigured defaults by typing show(install.rmosek). Apart from the typical arguments of install.packages, a user might want to change:

  • MSK_BINDIR: The location of the MOSEK library to compile against; e.g., mosek/<MSKVER>/tools/platform/<PLATFORM>/bin.

  • using_pkgbuild: Whether to run the installation in the build-friendly environment of package pkgbuild (helps, e.g., to resolve Rtools on Windows).

  • using_sysenv: Whether to transmit configuration variables via Sys.setenv() as opposed to configure.vars (depends on platform support).

4.3 Testing the Installation

First of all, to check that the Rmosek package was properly installed, start R and try


The installation can further be tested by running some of the enclosed examples. Open a terminal, change folder to <EXDIR> and use R to run a selected example, for instance:

R -f lo1.R