Matlab app compiler project doesn't work when loading a project file

25 次查看(过去 30 天)
I have a problem when using the Matlab app compiler app to compile my project. I add all the needed files, compile the project, test it and it works. If I now save all the added files to the project file, and later load the project file again to compile again, it compiles, but I get a runtime-error in the app. This error stems from the compiler not being able to find one of my files, but I checked and that file is explicitly added. It is added under the <fileset.main> directory in the project file, so should not be a problem.
Does anyone have any clue to what is going on? Thanks.

回答(1 个)

Nihal
Nihal 2024-1-3
此 个回答 已被 Daniel Conlon 标记
Hi Jacob,
I understand that you are facing issue with the app compiler. It sounds like you're encountering a path resolution issue during runtime after compiling your MATLAB application. When you compile an application with MATLAB Compiler, it packages the files and resolves paths based on the state of the MATLAB environment at compile time. If a file is not found at runtime, it typically means that either the file was not included in the compiled application or the application is looking for the file in a location that is different from where it was packaged.
Here are some steps you can take to troubleshoot the issue:
  • Check the Compilation Log: After compiling the application, MATLAB generates a log file that contains information about the files that were included in the compilation. Check this log to confirm that the missing file was indeed packaged.
  • Examine the Code: Look at the code that is generating the runtime error. Check for any lines that load or reference external files. Make sure that these files are being referenced by their correct paths. If you're using relative paths, it might be worth changing them to absolute paths for the sake of the compilation.
  • Use `mcc` Options: When using the `mcc` command for compiling, you can specify additional options to include all necessary files. For instance, you can use the `-a` option to add files or directories to the package manually.
  • Test in a Clean Environment: Before compiling, test your application in a clean MATLAB environment. You can do this by using the `matlab -nodesktop -nosplash -nojvm` command. This will help you identify any dependencies that you might have missed because they were present in your MATLAB path but not included in the compilation.
  • Dependency Analysis: Use the Dependency Analyzer in MATLAB to check for any files that your application depends on. This can help you ensure that all necessary files are included during compilation.
  • Runtime Path Adjustments: If your application requires dynamic path adjustments at runtime (e.g., if it needs to load files from user-specified directories), make sure that your code correctly handles these paths.
  • MATLAB Version: Ensure that the MATLAB version you're using to compile the application is the same as the one you're using to run the compiled application. Incompatibilities between versions can sometimes cause issues.
  • Recompile: If you've made changes to the project file or the list of included files, recompile the application to ensure that all changes are included in the new executable.
If possible provide detailed information about the error message you receive at runtime, as this can offer clues to the nature of the problem.

类别

Help CenterFile Exchange 中查找有关 MATLAB Compiler 的更多信息

产品


版本

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by