MATLAB: Is the CTF-archive only partially extracted when running the application created with MATLAB Compiler 4.2 (R14SP2)

MATLAB Compiler

When executing an application created with MATLAB compiler, some files are occasionally missing from the "application"_mcr directory where "application" is the name of my shared library, standalone executable, or other object created with MATLAB Compiler. If I manually extract the CTF-file using the extractCTF utility, all the files are present. As a result the application fails with an error message similar to
??? Undefined function or variable 'foo'.

Best Answer

Since manual extraction of the CTF-file results in all files being extracted properly, the CTF-file is not corrupt.
Most likely this is caused by some type of conflict or issue with the file system where the CTF-file is located.
If you are using a shared library here is some additional information and error checking you can perform. The call which extracts the CTF is "application"Initialize. This call is synchronous, so when it returns all the files should be present in the "application"_mcr directory. The CTF-file is just a ZIP-file with a different extension. As a result, one option would be to manually extract the CTF-file prior to initializing the library. This way the CTF-file will not need to be extracted and this problem can be avoided. You can do this with the extractCTF utility or with any unzip utility, as long as the proper directory structure is preserved. If you want to check for proper extraction, you should verify that all files in the CTF archive are present in the "application"_mcr directory.
If you are using an older version of MATLAB Compiler, there is a lot of benefit to moving to a more recent version of the compiler. There have been many fixes, including fixes in application initialization to the compiler between MATLAB Compiler 4.2 (R14SP2) and MATLAB Compiler 4.5 (R2006b).