During program generation, the MATLAB Compiler embeds the absolute path to MEX-files inside the application. When the application is run on another machine, it will look in a predefined location for required MEX libraries.
The MGLINSTALLER adds commonly used MEX-files to a target machine. However, some MEX-files are not distributed. These may include:
1. User generated MEX-files
2. MEX-files hidden in private directories
3. MEX-files included with MATLAB toolboxes that were not shipped on the installation CD
In order to ensure proper execution of a distributed application, MEX-files of the aforementioned type must be manually installed along with the program. The files must be placed in the 'bin' directory, which is the same directory as the executable.
MEX-files installed under a private directory in MATLAB must also be installed in a private directory with the distributed application. Here is an example:
If your program makes use of MEX-files found on the development machine in the following location:
$MATLAB\toolbox\foo\bar1.dll
$MATLAB\toolbox\foo\private\bar2.dll
(where $MATLAB is the root MATLAB installation directory)
then the files 'bar1.dll' and 'bar2.dll' must be installed with the application at the following location:
$APPLICATION\foobar.exe
$APPLICATION\bin\bar1.dll
$APPLICATION\bin\foo\private\bar2.dll
(where $APPLICATION is the root application installation directory)
To determine the MEX-files used by an application, look for generated files with the name of the form mex_interface.c. In the previous example, the compiler would generate bar1_mex_interface.c and images_private_bar2_mex_interface.c.
NOTE: The above workaround does not work for compiled applications that make use of functions from the Image Processing Toolbox. Please reference the following solution if this is the case:
Solution 1-1A3JV: Why does my stand-alone application fail to find MEX-files from 'private' folders in the MATLAB toolboxes when deployed?
Best Answer