Why does my ctfroot have unexpected subfolders?

Hi
I'm running a deployed executable, in which I load myfile.jpg. I access the file using:
AppRoot=ctfroot;
if isdeployed
matlabImage = imread(strcat(AppRoot,'\myfile.jpg'));
However the file is not found, because it is actually located in this subfolder of ctfroot:
Capture.JPG
As it happens, all the source files and myfile.jpg live in C:\AQUAscat_Toolkit, which is where I'm running my compiler, but I haven't explicitly included that path in the compiler settings, so why has it put it in a subfolder and not in the root? It seems to be using absolute rather than relative paths. I cannot find any setting to change the source file root. Also, since the subfolder in ctfroot is a truncated version of the original, how safe would it be to assume that my file will always be in a subfolder with that name?

4 Kommentare

Same problem here. The subfolder seems to be named according to the first 12 characters of the name of your program. I can't find any documentation on this.
If you don't mind that the user can access the data in the installation folder, you can just forget about the ctfroot, use relative paths, and in the Application Compiler put the file(s) under "Files installed for your end user".
Kees Aalbers
Kees Aalbers am 16 Aug. 2019
I have the same problem here, I've been digging but cannot find the cause. I had a previous build (2018a) which put the folders (mcc commands: -a <directory> -I<directory> ) in the cftroot. Yet after installing Matlab (Compiler) 2019a alongside 2018a, in order to use some new functionality, I got this problem. Now, when I try the following, the folders are all added to the subdirectory in cftroot...
  • Run mcc in Matlab 2018a
  • Run mcc in Matlab 2019a
  • Run mcc in cli (which triggers the 2019a mcc in my case)
  • Run C:\Program Files\MATLAB\R2018a\bin\win64\mcc.exe "-m ...." in cli
  • Run C:\Program Files\MATLAB\R2019a\bin\win64\mcc.exe "-m ...." in cli
  • Run C:\Program Files\MATLAB\R2018a\bin\mcc.bat "-m ...." in cli
  • Run C:\Program Files\MATLAB\R2019a\bin\mcc.bat "-m ...." in cli
When reading the mcc documentation the description of option -a reads the following: "...When you use the -a option to specify a full path to a resource, the basic path is preserved, with some modifications, but relative to a subdirectory of the runtime cache directory, not to the user's local folder. The cache directory is created from the deployable archive the first time the application is executed. ..."
I guess, this explains why it is put in the subdirectory, yet I do not understand why it does now and not before. And also that I cannot reproduce it...
Who can shine some light on this?
Alternatively, in line with Loren's blog, you could use the 'which' approach as mentioned in section: Paths as Arguments to MATLAB Functions. But I agree, this is an (ugly) workaround.
What is "cli"?
cli - command line interface

Melden Sie sich an, um zu kommentieren.

Antworten (1)

Bereketab Gulai
Bereketab Gulai am 8 Okt. 2019

0 Stimmen

The issue whereby the resource location was changed after several times of compiling. Occurred because the resources folder added was not in the matlab path.
Try it and add the all paths to the matlab session during compiling.

Kategorien

Produkte

Version

R2013b

Gefragt:

am 6 Mär. 2019

Kommentiert:

am 8 Okt. 2019

Community Treasure Hunt

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

Start Hunting!

Translated by