MATLAB: Do I receive an error when I call the MATLAB Compiler 4.0 (R14) generated shared library from another shared library

compiledcompilerdlldll_attach_processhanglibnameinitializelibraryMATLAB Compilershared

There is a problem when a MATLAB shared library (as generated by the MATLAB Compiler) is loaded by another shared library. The MATLAB library initialization function (e.g., <lib-name>Initialize) can not be called from the intermediate shared library during the DllMain(DLL_ATTACH_PROCESS) call. This applies whether the intermediate shared library is implicitly or explicity loaded.

Best Answer

This bug has been fixed in Release 14 Service Pack 2 (R14SP2). For previous releases, please read below for any possible workarounds:
We have verified that documentation on the MATLAB Compiler-generated shared libraries is inadequate on this topic in the MATLAB 7.0 (R14) manual.
The problem is with the placement of the call to <lib-name>Initialize(). Placing the call during DllMain(DLL_ATTACH_PROCESS) [or CWinApp::OnInitInstance()] causes the application to hang. To avoid the problem, place the call somewhere after DllMain().