How can I compile a live script exporter?

9 次查看(过去 30 天)
I have created a live script export function with the help of this answer and I want to compile it into an executable.
It compiles into an exe, but when trying to execute I receive an error. I imagine it occurs because I am calling an internal function.
Is there a way I can get around this limitation?
The intention for this is to allow other applications such as Git view a text representation of live scripts.
Here's the very simple function which works well from MATLAB:
function mlxToLaTeX(mlxFilePath)
% Description:
% Function to convert a *.mlx file to LaTeX format text and display in
% the command window.
%
% Compile by running:
% mcc('-m', '-d', pwd, 'mlxToLaTeX.m');
%
% *************************************************************************
% Examples:
% mlxToLaTeX('someScript.mlx');
%
% See also matlab.internal.liveeditor.openAndConvert
tmpFile = sprintf('%s.tex', tempname);
matlab.internal.liveeditor.openAndConvert(mlxFilePath, tmpFile);
texCode = fileread(tmpFile);
delete(tmpFile);
fprintf('%s',texCode);
But when compiled, I recieve the following output:
!mlxToLaTeX someScript.mlx
Unable to resolve the name matlab.internal.liveeditor.openAndConvert.
Error in mlxToLaTeX (line 31)
MATLAB:undefinedVarOrClass
MATLAB version: 2019b
Thank you,
Ben

采纳的回答

Martin Knelleken
Martin Knelleken 2022-1-27
Hi Ben,
Thank you for using the Live Editor and for bringing this up!
Indeed, matlab.internal.liveeditor.openAndConvert is not supported by the MATLAB complier. You should have seen warnings while running the compiler already. Something like: 'The file or function has been excluded from packaging for the "MCR" target environment'. One reason is that this is an internal function which is not made for public use and therefore it's not neccessarily supposed to work with the compiler.
We're actively working on a public replacement for openAndConvert. I can't promise that the first version of that will be fully supported by the compiler but we'll definitively attach importance to that.
Thanks
- Martin

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Install Products 的更多信息

产品


版本

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by