3

I have a software that has multiple GUIs. To organize things better (or at least that was my thought), I have created several folders within the root directory as it can be seen in this image.

enter image description here

Within the folders i have both files with different formats and also some Matlab scripts.

When creating the Matlab executable using the Application compiler, and after selecting the main file, Matlab does not directly detected that these same folders are important for the code to run. Therefore I decided to add the folders manually.

Once the setup is created and installed, by running the application within the Matlab environment, I was able to debug one possible issue why the software is not running.

enter image description here

As you can see in the first image, the "play.png" is within the Images folder.

My question is pretty straight forward: how to force the Matlab Compiler to learn that all these folders are to be included in the setup? Not only to be included but their paths'

16per9
  • 502
  • 4
  • 17

1 Answers1

1

Two things could be going on:

  1. You are not including the files in the package. Make sure that you include them using the -a option of mcc:

    mcc -m hello.m -a ./testdir/*
    

    You can also use the GUI, of course, see here.

  2. You are looking for the included files in the wrong place. Use ctfroot as the root of all paths in your code:

    img_file_name = fullfile(ctfroot,'Images','brain.jpg'));
    

    Check the unpacked CTF file (it is automatically unpacked when executed) to see the directory structure in it. ctfroot points to the root of the unpacked CTF file.

PS: This blog post might give you some more pointers.

Cris Luengo
  • 55,762
  • 10
  • 62
  • 120
  • Cris the "-a" option, how can I use it? Should I continue to use the Application Compiler or should I use the command line? – 16per9 Jan 09 '18 at 14:35
  • Already tried all that options, including removing the "ADDPATH" issues that popped up afterwards. Still the software does not fully runs. The images are now being recognized but important packages included in some of the folders are still not being correctly created. – 16per9 Jan 10 '18 at 14:25
  • @16per9, what do you mean with "important packages are not being created"? Is it not adding files to the CTF? Is it adding them but your code doesn't find them? Are source code files missing? – Cris Luengo Jan 10 '18 at 14:31
  • Inside the folder LDOF_src, there are multiple mex files, c++ and also matlab scripts. After compiling, when checking the tempfolder in the AppData, the LDOF_src folder is there, but with like 50% of the scripts that he should have. It is very strange... – 16per9 Jan 10 '18 at 14:33
  • An example: The file 'C:\Users\LDOF_src\compileDir.m' is not in the application's expanded CTF archive at 'C:\Users\AppData\Local\Temp\mcrCache9.1\KimaMa0'. If I copy this path and go check it, the *.m is not there. But it is in the original folder of creation... – 16per9 Jan 10 '18 at 14:35
  • Only the M-files actually used are added. If you use any of these through `feval` or the like, you need to add `%#pragma`: https://www.mathworks.com/help/compiler_sdk/ml_code/function.html – Cris Luengo Jan 10 '18 at 14:53
  • C++ files are not needed either. Don't tell me you're trying to create MEX-files at run time!? – Cris Luengo Jan 10 '18 at 14:54
  • Anyway, `-a ./dir/*.cpp` would force all .cpp files to be added. Repeat for .m, .mex, whatever else. – Cris Luengo Jan 10 '18 at 14:56
  • I'll try that last part to see if it recognizes. – 16per9 Jan 11 '18 at 14:57
  • Didn't work. in addition, using the function "ctfroot" is now giving me error saying that I don't have permission to write in the ouput directory. :( I am out of ideas... – 16per9 Jan 12 '18 at 15:43
  • `ctfroot` is the location of the files in the CTF. You cannot write to that directory, you cannot modify the CTF from your code. You need to use `ctfroot` to find your input files (the ones that come packaged inside the CTF), and write your output files to a directory specified by your used. Ask your user where s/he wants to write files, that's always the best way. – Cris Luengo Jan 12 '18 at 16:09
  • There's a possibility that MCC will not add M-files that are not called by the code, I don't know. The question is: what exactly are you trying to do? Why are you trying to add C++ files? There should be no need to explicitly add any files to your CTF except data files (such as your images). – Cris Luengo Jan 12 '18 at 16:15
  • Cris, those files are important and are also being called by the software because there are pipelines that run throught C++ on Matlab, through the mex files. It is quite tricky to explain. To ease, just think of it as an algorithm that Matlab calls to perform one action. – 16per9 Jan 15 '18 at 15:55
  • 1
    I did it @Cris! :D The main issue was the C++ files. One of the C++ files had a directory problem and therefore... yeah, one simple directory just breaking all the compiler! Dude thanks for your support := – 16per9 Jan 17 '18 at 15:12