Embedding existing executable into a compiled Matlab executable

6 views (last 30 days)
I have a .m script which calls an executable via the eval() command. I would like to compile this into a new executable using deploytool. However, when I attempt this the new executable fails because the .exe it is trying to call is not present. Is it possible to compile everything (the .m script & the executable it calls) into a single .exe file, or am I forced to have two .exe's? Appreciate the help.

Answers (1)

Kojiro Saito
Kojiro Saito on 3 Sep 2017
I have two ieas.
  • Specify full path of the executableRather than input relative path (for example, hoge.exe), you can specify full path. For example,
commandName = 'C:\Programs\hoge.exe -a option1 -b option2';
% Or, if the execution is located in the folder which includes a space, use double-quotation(")
%commandName = '"C:\Program Files\hoge.exe" -a option1 -b option2';
expression = '[status,cmdout] = system(commandName)';
eval(expression);
  • Include the exe file to Files installed for your end userIn MATLAB Compiler window, you can add the execution in "Files installed for your end user". In this case, you will have two execution files, one is compiled MATLAB application and the other is the exe which is called in m script, but the installer will put both execution files in the same folder.
Hope this work.
  1 Comment
Marc Youcef
Marc Youcef on 10 Oct 2018
Regarding the first idea : If the aim is to try to get hoge.exe embedded into the new MATLAB compiled executable then which path should be gave for hoge.exe? I only know that if files are embedded into the final MATLAB executable they should be accessed thanks to which() function but how this should apply to a command string through system() function?

Sign in to comment.

Categories

Find more on Introduction to Installation and Licensing in Help Center and File Exchange

Products

Community Treasure Hunt

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

Start Hunting!