4. Installation


In order to use the MOSEK optimization toolbox for MATLAB, you must install the MOSEK optimization tools. Please see Chapter 2 in the MOSEK installation manual for details on how to install MOSEK. An online version is available at

http://www.mosek.com/documentation/

4.1. Locating the toolbox functions

By default MATLAB cannot locate the MOSEK optimization toolbox functions. Therefore you must execute the addpath command within MATLAB to change the so-called matlabpath appropriately. Indeed matlabpath should include a path to the MOSEK optimization toolbox functions. The next subsections show how to use addpath.

4.1.1. On Windows

If you are using Windows you should do

% For MATLAB 7.9 (R2009b) or any later version do
addpath 'c:\Program Files\mosek\6\toolbox\r2009b'

% For MATLAB 7.4 (R2007a) to MATLAB 7.8 (R2009a)
addpath 'c:\Program Files\mosek\6\toolbox\r2007a'

% For MATLAB 7.3 (R2006b) do
addpath 'c:\Program Files\mosek\6\toolbox\r2006b'

This assumes that you installed MOSEK at

c:\Program Files\

If this is not the case, you will have to change the path given to addpath.

4.1.2. On Linux/UNIX/MAC OS X

If you are using UNIX or a UNIX-like operating system you should do

% For MATLAB 7.9 (R2009b) or any later version do
addpath '/home/user/mosek/6/toolbox/r2009b'

% For MATLAB 7.4 (R2007a) to MATLAB 7.8 (R2009a)
addpath '/home/user/mosek/6/toolbox/r2007a'

% For MATLAB 7.3 (R2006b)
addpath '/home/user/mosek/6/toolbox/r2006b'

This assumes that MOSEK is installed at

/home/user

If this is not the case, you will have to change the path given to addpath.

4.1.3. Permanently changing matlabpath

Normally, you will have to enter the addpath command every time MATLAB is started. This can be avoided if the addpath command is added to

<matlab>toolbox\local\startup.m

where <matlab> is the MATLAB root directory. Alternatively the permanent modification of the MATLAB path can be performed using the

\File\Set Path

menu item.

4.2. Verifying that MOSEK works

You can verify that MOSEK works by executing

mosekopt

in MATLAB. You should get a message similar to this:

MOSEK Version 3.1.1.62 (Build date: Dec 16 2004 11:49:51)
Copyright (c) 1998-2004 MOSEK ApS, Denmark. WWW: http://www.mosek.com


    MOSEK command summary.

        [r,res]=mosekopt(cmd,prob,param,log)

If you do not get this message, please read Section 4.3.

4.3. Troubleshooting

4.3.1. ??? Undefined function or variable 'mosekopt'

If you get the MATLAB error message

??? Undefined function or variable 'mosekopt'

you have not set up the matlabpath correctly as described in Section 4.1.

4.3.1.1. Unable to load MEX-file

One reason can be that you are not adding the correct path to the matlabpath, e.g. you may be trying to use the MOSEK optimization toolbox build for MATLAB 7 in MATLAB 6.

The other possible reasons are discussed below.

  • Windows: MATLAB prints an error message similar to this:

    DLL load failed for mex file
    c:\mosek\3\tools\toolbox\14sp3\mosekopt.dll The
    specified procedure could not be found. ??? Invalid MEX-file
    

    Most likely this problem is caused by the fact that MOSEK cannot load the MOSEK DLL which in turn is caused by the environment variable

    PATH
    

    not being appropriately set up.

    Please consult the MOSEK installation manual to learn how to install MOSEK under Windows and how to set up the operating system variable PATH.

  • MAC OS X: The DYLD_LIBRARY_PATH environment variable is not appropriately set up. Setting this variable can be tricky, in particular if you are invoking MATLAB by clicking on the MATLAB icon. In this case a file named

    $HOME/.MacOSX/environment.plist
    

    with a proper content should exist on your computer. Further details about environment.plist and how to install MOSEK under MAC OS X are available in the MOSEK installation manual.

  • UNIX: MATLAB prints an error message similar to this:

    Unable to load mex file:
    /usr/local/mosek/4/toolbox/14sp3/mosekopt.mexglx.
    libmosek.so.2.5: cannot open shared object file: No such file or
    directory ??? Invalid MEX-file
    

    The cause of the problem is that the shared library

    libmosek.so.2.5
    

    cannot be loaded. Normally this problem is caused by the fact that the OS environment variable

    LD_LIBRARY_PATH
    

    is not appropriately set up. Please note that LD_LIBRARY_PATH may have another name on some UNIX systems. Please consult the MOSEK installation manual to learn how to install MOSEK under UNIX.

4.3.2. “libgcc_s.so.1 must be installed for pthread_cancel to work

This error is caused by the fact thatan old version of the

libgcc_s.so.1

library is included in the MATLAB distribution. One method of solving this is to execute

export  LD_PRELOAD=/usr/lib/libgcc_s.so

before running MATLAB.

Another workaround is to remove libgcc_s.so.1 from the MATLAB distribution. We suggest you rename

<matlab>sys/os/glnx86/libgcc_s.so.1

to

<matlab>sys/os/glnx86/BACKUP_libgcc_s.so.1.bak

which should solve the problem.

4.3.3. Using the MATLAB compiler

MATLAB scripts using MOSEK can be compiled with the MATLAB compiler. Below is a description of some possible errors and their solution.

4.3.4. Shadowing the m-file

If you encounter the error

The file
  '/tools/mosek/4/toolbox/r14sp3/mosekopt.mexglx'
appears to be a MEX-file. It shadows the M-file
'/tools/mosek/4/toolbox/r14sp3/mosekopt.m'
but will not execute properly at runtime, as it does not export a function
named 'mexFunction.'
??? Error executing mcc, return status = 1.

when compiling a MATLAB script using MOSEK, you must delete

c:\mosek\6\toolbox\<MATLABVERSION>\mosekopt.m

This should fix the compile error.

4.3.5. “Cannot find authentication file

If you encounter the error

Cannot find authentication file
'C:\mosek\4\toolbox\r2006b\mosekopt_mexw32.auth'.

??? Invalid MEX-file 'C:\mosek\4\toolbox\r2006b\mosekopt.mexw32': .

Try to remove any addpath commands from your code when compiling. Instead, specify the location of the MOSEK files with

-I  c:\mosek\4\toolbox\r2006b

in the compile command.

Wed Oct 21 21:22:12 2015