2

My client has a network that doesn't have access to the internet. They intend to buy (very few) Matlab licenses just for the development efforts of me and my colleague. For the operational use by their staff, however, I should compile my Matlab code to *.exe files so that the operators don't use up licenses just to execute my Matlab "app"/"solution" (the language seems to be changing these days). They won't actually have mcc licenses, so the compiling will be done on my home organization's network.

The problem is that when the compiled executable runs, there doesn't seem to be an obvious way to force it to use Matlab Compiler Runtime (MCR). If there are Matlab licenses on the target system, it can use that as well. The whole point of compiling, however, is to avoid using the few licenses on the client network so that the licenses are available for m-file development work when needed. So the unique feature about this situation seems to be that the target environment will eventually have both Matlab licenses and MCR, as well as the requirement that compiled executables use only the MCR rather than the Matlab licenses.

The Mathworks is looking into the problem, but prospects of finding a solution are unclear. I am hoping that it won't involve manual rejigging login scripts to customize environment PATH variables, as that will break whenever login scripts are updated. I'm hoping for a solution like a pragma-like statement in the top-level m-file, or an mcc switch. In perusing the mcc documentation, however, no switches present themselves as likely candidates except for -Y license.lic, and it's not clear how to use that.

With regard to the client, another limitation I face is that I don't want to pester them with trial-and-error (it's not their job). This is complicated by the fact that there is also no efficient way to convey electronic content to them, so quick, iterative trial-and error is out. As well, their target environment, with Matlab licenses, doesn't yet exist, though the process to get there is in the works. It's a bit of an chicken-and-egg problem; they are getting Matlab based on the assumption that we can find solutions for the challenges, but it's hard to derisk the assumption beforehand by investigating solutions when the target environment doesn't yet exist.

On my home organization's system, I also face the limitation that I don't have rights to install MCR. Hence, I can't undertake trial-and-error to identify an incantation or recipe that ignores the presence of Matlab licenses and forces the use of MCR. Not that I have the time to do that, as it is a very inefficient way to achieve this objective.

Because of the many circumstantial challenges, trial-and-error isn't the way to go, and I'm hoping there is a canned method for forcing the use of MCR over any Matlab licenses that might be present. I am using R2015b.

user36800
  • 2,019
  • 2
  • 19
  • 34
  • There shouldn't be any 'forcing' involved, it should be enough to install the MCR on client machines consuming your executable. I couldn't understand from your description - are you unable to do even that? – Ofek Shilon Jun 23 '18 at 20:38
  • I just initiated the communication to transfer executables to the client. Local testing to date consists of successfully running the executables on a stand-alone without Matlab. The eventual target environment will have both the MCR installed and access to Matlab licenses. In each one of those conditions in isolation, I know the executables will run. I want to eliminate uncertainty by having a way to *ensure* that executables will use the MCR rather than the Matlab license. I seek a canned solution because I can't currently duplicate that environment to try potential solutions. – user36800 Jun 23 '18 at 22:45
  • What OS(s) are used for compiling and deployment? – mhopeng Nov 27 '18 at 06:03
  • The client system was Windows 7 at time of posting, but it might become Windows 10 imminently. I don't have clear and constant visibility into the client network. TMW eventually came back with clarification of how the compiled executables choose whether to rely on a Matlab license or the MCR. I've posted the details as an answer to this question. – user36800 Jan 02 '19 at 19:50

2 Answers2

0

I am working with this exact deployment situation for OS X / Linux with Matlab 2015b. When you compile an application for a Unix-based OS, the compiler creates a shell script that is executed at startup. My solution is to modify this script to check for the presence of the runtime libraries. For example, on OS X (macOS):

  echo "Setting up environment variables"
  if [ -d "/Applications/MATLAB/MATLAB_Compiler_Runtime/v90" ] ; then
    echo "Using MCR v8.6 (R2015b) (_Compiler)"
    MCRROOT=/Applications/MATLAB/MATLAB_Compiler_Runtime/v90
  elif [ -d "/Applications/MATLAB/MATLAB_Runtime/v90" ] ; then
    echo "Using MCR v8.6 (R2015b)"
    MCRROOT=/Applications/MATLAB/MATLAB_Runtime/v90
  elif [ -d "/Applications/MATLAB_R2015b.app" ] ; then
    echo "Using MATLAB R2015b application"
    MCRROOT=/Applications/MATLAB_R2015b.app
  else
    echo "No MATLAB libraries found! Install MCR R2015b from:"
    echo " http://www.mathworks.com/products/compiler/mcr/"
    echo " "
    sleep 10
    exit
  fi
mhopeng
  • 1,063
  • 1
  • 7
  • 17
  • Thanks, mhopeng, but the discussed host system (at time of posting) was Windows 7. Since then, we've heard rumours of an imminent migration to Windows 10, but no timeline was given. – user36800 Dec 31 '18 at 06:07
0

TMW's response:

Running a standalone application built with MATLAB Compiler will not check out any licenses whether running against an installed MATLAB Compiler Runtime or the runtime installed as part of a MATLAB Compiler installation. Note that end users with MATLAB installed without MATLAB Compiler will not have the compiler runtime libraries included with their installation.

If you have installed the MATLAB Compiler Toolbox, MATLAB will have a "runtime" folder with the necessary DLLs to execute the standalone application. Without the MATLAB Compiler Toolbox, these DLLs will not be available. Instead the user must install MCR to run the standalone application...the user cannot forgo the installation of MCR if they do not have the MATLAB Compiler Toolbox installed and they wish to run the standalone application.

Community
  • 1
  • 1
user36800
  • 2,019
  • 2
  • 19
  • 34