0

I'm using MATLAB R2015a application compiler. After choosing my main m-file, MATLAB found some files required for application to run but after compiling and running my application, the compiled application can't find some specific m-files from an installed toolbox (third-party toolbox).

Now i want copy all toolbox files to target folder C:\Users\My_Account\AppData\Local\Temp\My_Account\mcrCache8.5\Program_70\DDM. DDM is my toolbox folder that MATLAB creating it automatically based on nested files as mentioned above. I want add other files to this folder. How can I do this? and is this a good solution to fix this problem?

Eghbal
  • 3,892
  • 13
  • 51
  • 112
  • You should find out why compiler did not find files in third party toolbox. Copying to temp folder of mcr is not a good solution. You can add additional files when compiling. – Navan Jul 20 '15 at 22:32

1 Answers1

1

What you're trying to do won't work.

When you compile an application with MATLAB Compiler, it finds all code that your main function depends on, encrypts it, and packages it into an executable that will later be executed against the MATLAB Compiler Runtime (MCR).

The MCR can only execute code that has been encrypted and packaged in this way - it is not possible to get it to execute a regular unencrypted MATLAB file. So dumping things into the temp folder that the MCR uses to unpackage code files will not achieve anything.

Instead try to figure out why, during the dependency analysis, MATLAB Compiler is not finding all the files that your main function depends on.

There are various reasons why that might happen - the dependency analysis is not perfect. For example, if your code calls eval('myfunction'), the dependency analysis will not find myfunction. I answered another question recently where another cause was the issue.

In these situations you can explicitly tell MATLAB Compiler that there is a dependency on myfunction, using the %#function pragma. Within the file that contains the hidden call to myfunction, at the top of the file (actually anywhere, but typically you'd put it at the top), put

%#function myfunction

MATLAB Compiler will then force that to be a dependency and include it in the packaging.

Alternatively, when setting up the packaging with mcc or in the deploytool app, you can just manually add myfunction to the package yourself (although this will then not find things that myfunction depends on).

Community
  • 1
  • 1
Sam Roberts
  • 23,951
  • 1
  • 40
  • 64