How to call a .p file from another location in a deployed application

2 visualizaciones (últimos 30 días)
I have a MATLAB code deployed as an exe application using Compiler. In that MATLAB code, I would like to call and execute a .p file which is located in some other folder location. Is there a suitable way to do it ? I read that addpath cannot be used in deployed applications ?
The idea is that I am having a set of functions f1,f2,f3....,fn. All the pre-processing and post-processing are common for these functions. So I have kept this in a MATLAB code and deployed as exe. The functions are written in separate .m and protected as .p. Now if I have to add a new function, I need to create only a .p file and copy it to a location.
I am also trying to add my .exe concept
function MyApplication(function_file_path)
% Preprocessing
% call function_file_path (.p file)
Can addpath be used since this is a deployed application ?
% Postprocessing
end

Respuesta aceptada

Walter Roberson
Walter Roberson el 19 de Sept. de 2018
Editada: Walter Roberson el 19 de Sept. de 2018
Deployed executables must have all .m and .p files available at the time of compilation. They are encrypted and included in the .ctf and are executed in encrypted form. It is never possible to evaluate unencrypted .m or .p from a deployed executable.
The closest you can get is that loadlibrary() can be used to call into external shared objects whose contents do not have to be fixed at the time of deployment, as long as the API does not change. It would be valid to have an initialization layer that looked into a folder to find and catalog .dll and to return their names or identifiers, with calllib() being used to call to the consistent interface layer that would call into the plug-ins some-how. I do not think it would be possible to write the plug-ins in MATLAB and I do not think it would be possible to use engOpen() and related
"Engine applications require an installed version of MATLAB; you cannot run the MATLAB engine on a machine that only has the MATLAB Runtime"
  5 comentarios
Varun Pai
Varun Pai el 19 de Sept. de 2018
Thank you for all these information and sorry for disturbing you again.
As you said, loadlibrary() can be used, but loadlibrary and NET.addAssembly() cannot load libraries that are compiled using MATLAB. Isn't it ? which means I have to write a C/C++ application or C# application compile and then load in deployed MATLAB application.
Walter Roberson
Walter Roberson el 19 de Sept. de 2018
It just might be possible to carefully construct calls into a shared library created by MATLAB Compiler SDK; the wording at https://www.mathworks.com/help/compiler_sdk/cxx/calling-a-shared-library.html hints it might work. But it would not surprise me if it did not work, on the basis that the CTF generated by MATLAB Compiler SDK might not happen to have the same encryption key as the one generated by MATLAB Compiler, so it might not be possible to initialize everything properly.
... I don't know.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Get Started with MATLAB Compiler SDK en Help Center y File Exchange.

Productos


Versión

R2017a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by