Filter löschen
Filter löschen

Why no output from standalone application when run in Windows?

6 Ansichten (letzte 30 Tage)
KAE
KAE am 6 Mär. 2024
Bearbeitet: KAE am 7 Mär. 2024
How can I see the output from a standalone application compiled from Matlab, when I run the application in Windows?
Here's what I tried, but no output is shown. First, the mfile,
function [numOutput1, numOutput2, strOutput1, strOutput2] = test_compiled1(numInput1, numInput2, strInput1, strInput2)
% Convert inputs to numeric
if isstr(numInput1)
numInput1 = str2double(numInput1);
end
if isstr(numInput2)
numInput2 = str2double(numInput2);
end
% Do something with inputs and outputs
numOutput1 = numInput1.^numInput2;
numOutput2 = numInput1 - numInput2;
strOutput1 = [strInput1 '_' strInput2];
strOutput2 = [strInput2 '_' strInput1];
%% Return the output by displaying the results
disp([num2str(numOutput1) ' ' num2str(numOutput2) ' ' strOutput1 ' ' strOutput2 ])
When I run it in Matlab, it displays the output,
test_compiled1(2, 3, 'a', 'b')
8 -1 a_b b_a
Then I compile it as follows,
fileMatlab = 'test_compiled1.m';
buildResults = compiler.build.standaloneApplication(fileMatlab);
compiler.package.installer(buildResults);
In Windows, I navigate to the directory that test_compiled1.exe is in, and run it as follows,
.\test_compiled1.exe 2 3 "a" "b"
Nothing is displayed and it takes ~30 seconds to run. Putting a and b in single quotes or no quotes at all doesn't change this. And if I pipe the output to a log file and an error file, both are empty.
.\test_compiled1.exe 2 3 "a" "b" >output.log 2>error.log
How can I see the output of this standalone application from Windows?

Akzeptierte Antwort

KAE
KAE am 7 Mär. 2024
Bearbeitet: KAE am 7 Mär. 2024
The solution had nothing to do with the code. I had multiple copies of test_compiled1.exe in different directories. When I deleted them all, compiled as shown above, then ran it from the Windows command line, it successfully displayed the output or piped it to a log file, though it does take 11 seconds to run and only 1 s when I run the mfile in Matlab.
I won't delete this question in case it helps someone who needs a simple example.

Weitere Antworten (0)

Kategorien

Mehr zu Application Deployment finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by