Including multiple folders (with images, scripts, etc) within a Matlab standalone GUI.exe - matlab

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.
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.
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'

Two things could be going on:
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.
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.

Related

add path to subfolder containing dependeble .m files that are not bundled in the compilation

I am trying to deploy an application which are dependent on specific data input files in the form of .m files.
I know how to bundle all of the files "freezing" them within the compilation: like so mcc -m file.m -a path_to_data*.m.
However, I was wondering if it is possible to just add the path to the data folder into the deployment project and then have the data files within the folder being interchangeable (i.e. being added to the MATLAB path upon execution and not freezed during compilation). The advantage of this would be that the application could still be used if some data files needed to be changed without having to recompile everything.
What would be the best way to do this? Is it possible with the MATLAB compiler?
ps. I am working on a unix system

remove curve fitting toolbox for packaging

I have a matlab guide program I want to compile (package).
This program is not using the curve fitting toolbox.
Nevertheless the compiler complains about a missing licence.
mcc -C -o ...
Compiler version: 5.0 (R2013b)
Dependency analysis by DEPFUN.
Processing C:\Program Files\MATLAB\R2013b\toolbox\matlab\win64\mcc.enc
Processing C:\Program Files\MATLAB\R2013b\toolbox\curvefit\win64\mcc.enc
Depfun error: 'License checkout failed.
License Manager Error -4
Maximum number of users for Curve_Fitting_Toolbox reached.
How can I remove this dependancy for compilation?
According to the mcc document,
-N Clear Path
Passing -N effectively clears the path of all folders except the following core folders
(this list is subject to change over time):
matlabroot\toolbox\matlab
matlabroot\toolbox\local
matlabroot\toolbox\compiler\deploy
It also retains all subfolders of the above list that appear on the MATLAB path at compile time.
Including -N on the command line lets you replace folders from the original path,
while retaining the relative ordering of the included folders.
All subfolders of the included folders that appear on the original path are also included.
In addition, the -N option retains all folders that you included on the path that are not under matlabroot\toolbox.
In other words, you can clear all folders from the path and only keep the core MATLAB ones.
If you want to include some toolbox folders, you can use the -a option:
mcc ... -a C:\Program Files\MATLAB\R2013b\toolbox\...\...
Personally, I simply temporarily rename toolbox folders I don't need.
Just manually navigate to "matlabroot()\toolbox\" and rename, say, "signal" -> "signal_".
Surprisingly, the same could be done from the script, calling mcc() - almost no files in those folders are locked by matlab.exe.
This method doesn't sound like a "solution", of course it's just a "quick-and-dirty workaround". But, for me, it seem to work (R2015a).
Note, that you can easily check, what's actually included in your "deployed" dll (or exe), with 7z. Including files, added from toolboxes - see "my.dll.text\toolbox\"
PS1:
From my experience ,"-N" removes some unrelated stuff. Not all.
Moreover, when using "-N", you should carefully add stuff you need with "-I".
PS2:
In ".prj" file, created by deploytool(), there's something, that sounds related:
<matlab>
<root>D:\Program Files\MATLAB\MATLAB Production Server\R2015a</root>
<toolboxes>
<toolbox name="matlabcoder" />
...
</toolboxes>
...
</matlab>
but I've not checked, whether this actually controls witch toolboxes are used by mcc.

MATLAB compiler processes mcc.enc from unrelated toolboxes

I'm using mcc to compile my MATLAB project. The machine I'm using has many MATLAB toolboxes installed on it, but my code only requires a few (such as distcomp and images). However, whenever I run mcc, it ends up "processing" the mcc.enc files for many toolboxes, including those that my code does not need.
Here is the beginning of the output from mcc (I'm running it with -R '-nodisplay' to be compatible with the cluster I'm using).
Warning: No display specified. You will not be able to display graphics on the screen.
Compiler version: 4.15 (R2011a)
Processing /cm/shared/apps/matlab/7.12.0/toolbox/matlab/mcc.enc
Processing /cm/shared/apps/matlab/7.12.0/toolbox/distcomp/mcc.enc
Processing /cm/shared/apps/matlab/7.12.0/toolbox/images/mcc.enc
Processing /cm/shared/apps/matlab/7.12.0/toolbox/stats/mcc.enc
Processing /cm/shared/apps/matlab/7.12.0/toolbox/shared/imageslib/mcc.enc
Processing /cm/shared/apps/matlab/7.12.0/toolbox/shared/system/mcc.enc
Processing /cm/shared/apps/matlab/7.12.0/toolbox/shared/spcuilib/mcc.enc
Processing /cm/shared/apps/matlab/7.12.0/toolbox/control/mcc.enc
Processing /cm/shared/apps/matlab/7.12.0/toolbox/shared/controllib/engine/mcc.enc
Processing /cm/shared/apps/matlab/7.12.0/toolbox/shared/controllib/general/mcc.enc
Processing /cm/shared/apps/matlab/7.12.0/toolbox/signal/mcc.enc
Processing /cm/shared/apps/matlab/7.12.0/toolbox/nnet/mcc.enc
I've noticed it does the same thing when running mcc on my desktop as well. Some of these mcc.enc files (especially .../signal/mcc.enc and .../nnet/mcc.enc), take more time to process than it takes the rest of mcc to execute. Is there any way to exclude processing unneeded mcc.enc files?
Using the "deplyment tool" in the MATLAB IDE, go the project settings and from the "toolboxes on path" tab, unselect all toolboxes you do not need.
Also, there is an mcc argument -N that clears all folders from the path and only keep the core MATLAB ones.
-N Clear Path
Passing -N effectively clears the path of all folders except the
following core folders (this list is subject to change over time):
matlabroot/toolbox/matlab
matlabroot/toolbox/local
matlabroot/toolbox/compiler/deploy
It also retains all subfolders of the above list that appear on the
MATLAB path at compile time. Including -N on the command line allows
you to replace folders from the original path, while retaining the
relative ordering of the included folders. All subfolders of the
included folders that appear on the original path are also included.
In addition, the -N option retains all folders that the user has
included on the path that are not under matlabroot/toolbox.
I would recommend using the «fdep» function from the Matlab Central File Exchange:
http://www.mathworks.com/matlabcentral/fileexchange/17291-fdep--a-pedestrian-function-dependencies-finder
This function, applied to the main function of your program will tell you the toolboxes you are using and all the functions that are being used (recursively, so all the elemental functions are listed and you shouldn't miss any function). It is really useful to reduce the size and the compiling time of your final exe.

Developing with Qooxdoo and multiple developers

I'm interested in Qooxdoo as a possible web development framework. I have downloaded the SDK and installed it in a central location on my PC as I expect to use it on multiple projects. I used the create-application.py script to make a new test application and added all the generated files to my version control system.
I would like to be able to collaborate on this with other developers on other PCs. They are likely to have the SDK installed in a different location. The auto-generated files in Qooxdoo seem to include the SDK path in both config.json and generator.py: if the SDK path moves, the generator.py script stops working. generator.py doesn't seem to be too much of a problem as it looks in config.json for an updated path, but I'm not sure how best to handle config.json.
The only options I've thought of so far are:
Exclude it from the VCS, but there doesn't seem to be a script to regenerate it automatically, so this could be dangerous.
Add it to the VCS but have each developer modify the path line and accept that it might need to be adjusted whenever changes are merged.
Change config.json to be a path and a single 'include' line that points to a second file that contains all the non-SDK-path related information.
Use a relative path to the SDK and keep a separate, closely located copy of the SDK for every project that uses it.
Approach 1 would be ideal if the generation script existed; approach 2 is really nasty; I couldn't get approach 3 to work and approach 4 is a bit messy as it means multiple copies of the SDK littered about the place.
The Android SDK seems to deal with this very well (using approach 1), with the SDK path in its own file with a script that automatically generates that file. As far as I can tell, Qooxdoo puts lots of other important information in config.json and the only way to automatically generate that file is to create a new project.
Is there a better/recommended way to deal with this?
As an alternative to using symlinks, you can override the QOOXDOO_PATH macro on the command line:
./generate.py source -m QOOXDOO_PATH:<local_path_to_qooxdoo>
(Depending on the shell you are using you might have to apply some proper quoting of the -m argument). This way, every programmer can use his locally installed qooxdoo SDK. You can even drop the QOOXDOO_PATH entry from config.json to enforce this.
We work with a symbolic link pointing to the sdk ... config.json contains just the path of the link.

Compiling Matlab shared library with image processing toolbox

I'm trying to compile C shared library from Matlab. My Matlab code uses a lot of the image processing functionality. So, compiling goes fine, but when I call the dll from my application, I get messages like:
"Undefined function or method 'XYZ' for input arguments of type double".
I have verified my arguments are ok -- it's not a type problem. So, I tried adding %#function XYZ to my .m file, but that didn't help anything. Then, I tried using the -a flag in my compile command:
eval(['mcc -v -N -W lib:cshared -d ' clibdir ' -T link:lib -a edge' allFiles]);
but it fails to compile with:
Depfun error: 'Unable to locate edge as a function on the MATLAB path'
I have verified the image processing files are on my computer (I can run everything from matlab with no problem) and my path points to the directory that contains them.
I've also tried copying the toolbox .m files into my working directory, but that quickly balloons into a lot of files. And, for some functions, there is no .m - just a .mex - and i haven't found a way to include a mex file into my .dll.
What am I missing?
Have you tried including the Image Processing Toolbox folder using the -a option? For example:
mcc ... -a C:\Program Files\MATLAB\R2009a\toolbox\images\images
According to the mcc documentation, all files in this folder, as well as all files in any subfolders, are added to the CTF archive, and the folder subtree is preserved in the CTF archive.
If you don't want to include every subfolder, you can load only the files in a folder using a wildcard pattern:
mcc ... -a C:\Program Files\MATLAB\R2009a\toolbox\images\images\*
This may be necessary if there is a subfolder that may have functions or scripts that could shadow ones in the parent folder. For example, there is an edge.m function in the parent folder C:\Program Files\MATLAB\R2009a\toolbox\images\images\, and there is a ja subfolder that contains Japanese language help files (on Windows), one of which is also called edge.m. You wouldn't want this subfolder to be added when compiling, so you could either:
Remove that subfolder temporarily, add the parent folder without the wildcard option (to add the other subfolders you do want), then put that folder back.
Add the parent folder with the wildcard option (to add just the files), then separately add only the subfolders you want (such as #strel and private) with an additional -a command. NOTE: I'm uncertain if adding subfolders separately will maintain the folder subtree of the parent directory in the CTF archive in the same way as option #1 would!
If you don't want to include a large list of files that may not end up being used, you could instead try using the function DEPFUN to first get a list of dependencies for your MATLAB code. Then from this list you can find the specific Image Processing Toolbox functions your code uses and include only those when compiling. Since you specifically asked, this newsgroup thread mentions how to include a .mex file:
mcc ... -a imreconstructmex.mexw32 %# For a 32-bit Windows mex file
NOTE: There is also a MathWorks bug report I came across (which you need a login to see) that mentions a problem compiling applications using some Image Processing Toolbox functions on Windows in R2009b. There is a workaround given at the above link. This bug is fixed as of R2010a.