MATLAB: How to use both Compiler 3.x (R13) applications and Compiler 4.x (R14 and later) applications on the same machine

3.04.0interopMATLAB Compilerversion

I have multiple MATLAB Compiler-generated applications built using MATLAB Compiler 3.x (R13) and MATLAB Compiler 4.x (R14 and later). I would like to configure my system so that all of them can execute correctly.

Best Answer

This enhancement has been incorporated in Release 2007a (R2007a). For previous product releases, read below for any possible workarounds:
Starting with MATLAB Compiler 4.0 (R14), the MATLAB Compiler Runtime libraries (MCR) are versioned. This allows several MCRs to be listed on the library search path and Windows registry; see the Related Solution below for more specifics.
The equivalent libraries for MATLAB Compiler 3.x (R13) are not versioned. You must therefore execute Compiler 4.x applications in one environment with only Compiler 4.x libraries on the search path, and Compiler 3.x applications in another with only Compiler 3.x libraries on the search path.
This can be simplified using Batch files on Windows, and shell scripts on Linux/UNIX/Mac. For example, if you have two applications, myR13App and myR2006bApp, you could produce the following scripts using the library paths specified in the appropriate Compiler documentation.
This procedure assumes familiarity with Batch files or shell scripts. For more information, consult your operating system documentation. The example scripts below must be configured with the appropriate paths for your Compiler versions and operating system and are not ready to execute.
For example, for 32-bit Windows:
runMyR13App.bat:
set PATH=$MGLROOT\bin\win32;%PATH%

C:\work\myR13App.exe
where $MGLROOT is the installation of the R13 Math and Graphics Library (MGL). Including %PATH% on the set PATH line includes the previous value of that variable.
runMyR2006bApp.bat:
set PATH=$MCRROOT\$VERSION\runtime\win32;%PATH%
C:\work\myR2006bApp.exe
where $MCRROOT is the installation directory of the appropriate version of the Compiler 4.x MCR, and $VERSION is the version such as v75. Including %PATH% on the set PATH line includes the previous value of that variable.
For 32-bit Linux:
runMyR13App.csh:
#!/bin/csh
setenv LD_LIBRARY_PATH $MGLROOT/bin/glnx86:$LD_LIBRARY_PATH
/user/mylogin/myR13App
where $MGLROOT is the installation of the R13 Math and Graphics Library (MGL). Including $LD_LIBRARY_PATH (with an actual $) in the setenv LD_LIBRARY_PATH line includes the previous value of that variable.
runMyR2006bApp.csh:
#!/bin/csh
setenv LD_LIBRARY_PATH $MCRROOT/$VERSION/runtime/glnx86:$MCRROOT/$VERSION/sys/os/glnx86:$MCRROOT/$VERSION/sys/java/jre/glnx86/jre1.5.0/lib/i386/native_threads:$MCRROOT/$VERSION/sys/java/jre/glnx86/jre1.5.0/lib/i386/server:$MCRROOT/$VERSION/sys/java/jre/glnx86/jre1.5.0/lib/i386:$LD_LIBRARY_PATH
setenv XAPPLRESDIR $MCRROOT/$VERSION/X11/app-defaults
/user/mylogin/myR2006bApp
where $MCRROOT is the installation directory of the appropriate version of the Compiler 4.x MCR, and $VERSION is the version such as v75. Including $LD_LIBRARY_PATH (with an actual $) in the setenv LD_LIBRARY_PATH line includes the previous value of that variable.