4 Installation¶
In this section we discuss how to install and setup the MOSEK API for MATLAB.
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 API for MATLAB can be used with MATLAB version R2021a or newer on linux64x86
and win64x86
and R2023b or newer on osxaarch64
.
Locating files in the MOSEK Optimization Suite
The relevant files of the API for MATLAB are organized as reported in Table 4.1.
Relative Path |
Description |
Label |
---|---|---|
|
MATLAB files and libraries |
|
|
Examples |
|
where <MSKHOME>
is the parent folder in which the MOSEK Optimization Suite has been installed and <PLATFORM>
is one of linux64x86
, win64x86
or osxaarch64
.
Setting up the paths
To use API for MATLAB the path to the MATLAB files must be added via the addpath
command in MATLAB. Use the command
addpath <MSKHOME>/mosek/11.0/tools/platform/linux64x86/bin (linux64x86) addpath <MSKHOME>/mosek/11.0/tools/platform/osxaarch64/bin (osxaarch64) addpath <MSKHOME>\mosek\11.0\tools\platform\win64x86\bin (win64x86)
4.1 Testing the installation¶
You can verify that API for MATLAB works by executing
mosekcheck
in MATLAB. This should produce a message similar to this:
>> mosekcheck
Matlab version : 9.10.0.1739362 (R2021a)
Architecture : GLNXA64
MOSEK MeX path : /home/user/somepath/mosek/11.0/tools/platform/linux64x86/bin/mosekenv.mexa64
MOSEK version : 11.0.0
PTS license : Yes.
PTON license : Yes.
MOSEK works OK : You can use MOSEK in MATLAB.
In case of errors extra debug and license path information can be obtained with:
mosekcheck(debug = true);
4.2 Troubleshooting¶
Missing library files such as libmosek64.11.0.dylib or similar
If you are using macOS and get an error such as
Library not loaded: libmosek64.11.0.dylib
Referenced from:
/Users/.../.../.../mosekenv.mexmaca64
Reason: image not found.
then most likely you did not run the MOSEK installation script install.py
found in the bin
directory. See also the Installation guide for details.
Windows, invalid MEX-file, cannot find shared libraries
If you are using Windows and get an error such as
Invalid MEX-file <MSKHOME>\Mosek\11.0\tools\platform\win64x86\bin\mosekenv.mexw64: The specified module could not be found.
then MATLAB cannot load the MOSEK shared libraries, because the folder containing them is not in the system search path for DLLs. This can happen if MOSEK was installed manually and not using the MSI installer. The solution is to add the path <MSKHOME>\mosek\11.0\tools\platform\<PLATFORM>\bin
to the system environment variable PATH
. This can also be done per MATLAB session by using the setenv
command in MATLAB before using MOSEK, for example:
setenv('PATH', [getenv('PATH') ';<MSKHOME>\Mosek\11.0\tools\platform\win64x86\bin']);
See also the Installation guide for details.
Incorrect use of ‘=’ operator
An error such as
Error: File: mosekmodel.m Line: 491 Column: 49
Incorrect use of '=' operator. To assign a value to a variable, use '='. To compare values for equality, use '=='.
will appear if your MATLAB version is too old. See above for the minimal supported MATLAB version.
MOSEK does not see new license file
If you updated your license file but MOSEK does not detect it then restart MATLAB. MOSEK is caching the license and it will not notice the change in the license file on disk.
Undefined Function or Variable mosekenv
If you get the MATLAB error message
Undefined function or variable 'mosekenv'
you have not added the path to the API for MATLAB correctly as described above.
Security exception in MacOS 10.15+ (Catalina)
If an attempt to run MOSEK on Mac OS 10.15 (Catalina) and later produces security exceptions (developer cannot be verified
and similar) then use xattr
to remove the quarantine attribute from all MOSEK executables and binaries. This can be done in one go with
xattr -dr com.apple.quarantine mosek
where mosek
is the folder which contains the full MOSEK installation or MOSEK binaries. See https://themosekblog.blogspot.com/2019/12/macos-1015-catalina-mosek-installation.html for more information. If that does not help, use the system settings to allow running arbitrary unverified applications.