Failed to open file '...\mcr\t​oolbox\mat​lab\iofun\​@timer\tim​er.m'. Details: 'File stream is closed. The following flags are set: failbit.' when using plot in standalone exe

22 views (last 30 days)
My standalone application (executable file on Windows 10) works well in performing a variety of task: reading and writing files, executing third party software, make computations, plot charts, log diary, move files, etc. I also need to show the console during execution as it reports a diary of the operations performed, warnings, and some output data.
The final output data are a few lines on the console and a plot. The console is intended to reproduce the same output of the MATLAB command window. However, any time the mouse pointer is hovering on the plot generated by the standalone executable, the command line throws a long sequence of errors:
Failed to open file 'C:\Program Files\MATLAB\MATLAB Runtime\R2022b\mcr\toolbox\matlab\iofun\@timer\timer.m'. Details: 'File stream is closed. The following flags are set: failbit.'
Failed to open file 'C:\Program Files\MATLAB\MATLAB Runtime\R2022b\mcr\toolbox\matlab\iofun\@timer\timer.m'. Details: 'File stream is closed. The following flags are set: failbit.'
Failed to open file 'C:\Program Files\MATLAB\MATLAB Runtime\R2022b\mcr\toolbox\matlab\iofun\@timer\timer.m'. Details: 'File stream is closed. The following flags are set: failbit.'
Warning: Error occurred while executing the listener callback for event WindowMouseMotion defined for class matlab.ui.Figure:
The file
"C:\Program Files\MATLAB\MATLAB Runtime\R2022b\mcr\toolbox\matlab\iofun\@timer\timer.m"
cannot be executed.
Error in matlab.graphics.interaction.actions.Linger/startTimer
Error in matlab.graphics.interaction.actions.Linger/motionCallback
Error in matlab.graphics.interaction.actions.Linger
> In waitforallfiguresclosed (line 20)
Failed to open file 'C:\Program Files\MATLAB\MATLAB Runtime\R2022b\mcr\toolbox\matlab\iofun\@timer\timer.m'. Details: 'File stream is closed. The following flags are set: failbit.'
Failed to open file 'C:\Program Files\MATLAB\MATLAB Runtime\R2022b\mcr\toolbox\matlab\iofun\@timer\timer.m'. Details: 'File stream is closed. The following flags are set: failbit.'
Failed to open file 'C:\Program Files\MATLAB\MATLAB Runtime\R2022b\mcr\toolbox\matlab\iofun\@timer\timer.m'. Details: 'File stream is closed. The following flags are set: failbit.'
Failed to open file 'C:\Program Files\MATLAB\MATLAB Runtime\R2022b\mcr\toolbox\matlab\iofun\@timer\timer.m'. Details: 'File stream is closed. The following flags are set: failbit.'
Failed to open file 'C:\Program Files\MATLAB\MATLAB Runtime\R2022b\mcr\toolbox\matlab\iofun\@timer\timer.m'. Details: 'File stream is closed. The following flags are set: failbit.'
Failed to open file 'C:\Program Files\MATLAB\MATLAB Runtime\R2022b\mcr\toolbox\matlab\iofun\@timer\timer.m'. Details: 'File stream is closed. The following flags are set: failbit.'
Failed to open file 'C:\Program Files\MATLAB\MATLAB Runtime\R2022b\mcr\toolbox\matlab\iofun\@timer\timer.m'. Details: 'File stream is closed. The following flags are set: failbit.'
Failed to open file 'C:\Program Files\MATLAB\MATLAB Runtime\R2022b\mcr\toolbox\matlab\iofun\@timer\timer.m'. Details: 'File stream is closed. The following flags are set: failbit.'
Failed to open file 'C:\Program Files\MATLAB\MATLAB Runtime\R2022b\mcr\toolbox\matlab\iofun\@timer\timer.m'. Details: 'File stream is closed. The following flags are set: failbit.'
Failed to open file 'C:\Program Files\MATLAB\MATLAB Runtime\R2022b\mcr\toolbox\matlab\iofun\@timer\timer.m'. Details: 'File stream is closed. The following flags are set: failbit.'
Failed to open file 'C:\Program Files\MATLAB\MATLAB Runtime\R2022b\mcr\toolbox\matlab\iofun\@timer\timer.m'. Details: 'File stream is closed. The following flags are set: failbit.'
Failed to open file 'C:\Program Files\MATLAB\MATLAB Runtime\R2022b\mcr\toolbox\matlab\iofun\@timer\timer.m'. Details: 'File stream is closed. The following flags are set: failbit.'
Warning: Error occurred while executing the listener callback for event ButtonExited defined for class matlab.graphics.primitive.canvas.JavaCanvas:
The file
"C:\Program Files\MATLAB\MATLAB Runtime\R2022b\mcr\toolbox\matlab\iofun\@timer\timer.m"
cannot be executed.
This happened on R2022b on different machines with Windows 10. The exe provides the same results of the MATLAB script and everything works fine, except for the errors reported above. I tried to disable the interactivity of the plot, avoid moving files, using a different type of the plot: the issue is always present.
Due to the complexity and the confidentiality of my work I will report a minimum and generic working example that provides the same issue. It is sufficient to generate the executable file of the following code with the Application Compiler:
close all; clearvars; clc
A = magic(5);
plot(A,'o-')
grid on
title('Call it magic')
with the additional runtime setting "Do not display the Windows Command Shell..." disabled. I get something like the following screenshot.
Any advice on how to solve?

Answers (1)

Ganesh
Ganesh on 14 Sep 2023
The issue is non reproducible from my end, and may have to do with version mismatches of of MATLAB Runtime.
Kindly refer to this documentation for getting the appropriate version of MCR.
Feel free to reach out if the issue still persists.
Thanks and Regards,
Ganesh S

Categories

Find more on MATLAB Compiler in Help Center and File Exchange

Products


Release

R2022b

Community Treasure Hunt

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

Start Hunting!