I've narrowed the issue to the m-file which I compiled to a dll is not linking at run time. Here are some details:
1. The compiler chose at the Matlab R2011b-32bit commandline was Lcc-win32 C 2.4.1; however, the corresponding h and c files generated with the dll and lib have metadata stating that this is a MATLAB Compiler: 4.16 (R2011b). Looking through the header file, I notice LCC compiler switches. The reason I bring this up is that the literature states the the MCR and the Matlab compiler have to coordinate. In my case the MCR is 7.16 and the compiler should be 4.16.
2. Once this m-file based dll is built, I place it in the working directory and run the program. The program immediately crashes; the call stack indicates that the main function was not reached.
3. The debugger points to the line in gc_support.c:
#else /* defined (_WIN64) */ cookie = systime.ft_struct.dwLowDateTime; cookie ^= systime.ft_struct.dwHighDateTime; #endif /* defined (_WIN64) */
So my thoughts on this is that the Matlab compiler is not the correct one? Or, Microsoft VC 2010 is not set up correctly for linking in this m-file based dll?
Here is my general setup for VC 2110 project; hopefully this is helpful:
1. System path has MCR directory before Matlab.
2. Statically link in mclmcrrt.lib, and libut.lib from root\R2011b\extern\lib\win32\microsoft\ and LinearFitModelFnLib.lib (created from m-file) located in the working directory.
3. LinearFitModelFnLib.dll (created from m-file) located in working directory
4. All programs are 32 bit.
I hope this helps; please let me know if you need any more information.
Best Answer