Why are some of my functions 'Undefined' in my standalone executable compiled from MATLAB source and pcode files?
3 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Paul
el 19 de Abr. de 2024
Respondida: Walter Roberson
el 25 de Abr. de 2024
I have a MATLAB standalone app compiled from many different source code files. Some of the dependencies for this app are sensitive IP so I identified all required files using requiredFilesAndProducts and I obfuscated those sensitive dependencies (since source code is to be delivered as part of this project). Some of those dependencies use functions from other dependencies so I recursively called requiredFilesAndProducts to get a complete list of all required files. From that list, I then ran pcode against the sensitive IP and gathered all the pcode files into one location.
When I compile the standalone executable, I add the path to the pcode folder addpath(genpath('C:\path\to\pcode\folder')) as well as the safe to distribute MATLAB source code files and compile compiler.build.standaloneApplication('MATLAB_SOURCE_CODE_FILE_Y.m').
When I run the standalone app, some of the functions from the pcode will yield Undefined function 'Some_Function' for input arguments of type 'char'. Error in PCODE_FILE_X Error in MATLAB_SOURCE_CODE_FILE_Y (line 85) despite the fact that Some_Function has a corresponding pcode file in the pcode folder.
I tried listing at the bottom of the main function for the standalone app all the pcode files as other threads suggest but that doesn't solve the problem for pcode files referencing functions from other pcode files. Any ideas?
3 comentarios
Bruno Luong
el 19 de Abr. de 2024
Editada: Bruno Luong
el 19 de Abr. de 2024
>> any(~cellfun(@isempty, strfind(fList, 'Some_Function.p')))
ans =
logical
0
So that means the compiler cannot see by parsing the code that Some_Function.p is needed.
It might be called by some odd way such as EVAL or FEVAL. You might add this file manually bu hand using "-a" option pf MCC command.
The list of files that are packaged are in fList, you can check what else is missing.
You might repeat -a if similar issue with other files.
Respuesta aceptada
Más respuestas (1)
Walter Roberson
el 25 de Abr. de 2024
@David Leffingwell writes
Use the "-j" switch to the MATLAB Compiler to automatically convert all M files to P-code (in R2022b or later)
The "-s" option of the MATLAB Compiler doesn't obfuscate the M code, it obfuscates the file and folder structure inside the package and also supports encryption of data files.
It seems to me that adding those switches would be a lot easier than what you are currently doing.
0 comentarios
Ver también
Categorías
Más información sobre Programming Utilities en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!