MATLAB: Problems with Matlab C compiler, lcc-win32, and Microsoft SDK 7.1

lcc-win32microsoftvisualc++sdk7.1

I have 15 year old innerpart.c. I compiled it 15 years ago, as innerpart.dll, with now ancient versions of Matlab and Microsoft Visual C++. It worked just fine in my ancient version of Matlab. However when I run it in Matlab 2013a it works but gives a warning
EDU>> innerpart(1:3,1)
Warning: Calling MEX-file 'd:\!mydocs\matlab\mexFiles\innerpart.dll'.
MEX-files with .dll extensions will not execute in a future version of MATLAB.
ans =
6.0000 + 0.0000i
I moved innerpart.dll elsewhere.
So it is time to recompile. I ran mex -setup and selected Matlab's built in C compiler. It seemed to compile and link successfully but when I try to run it, it says
EDU>> innerpart(1:3,1)
Invalid MEX-file 'd:\!mydocs\matlab\mexfiles\innerpart.mexw32': The specified procedure could not be found.
That is interesting. When I look in folder mexfiles I see innerpart.mexw32. So why can't Matlab see it? I executed it from the parent directory of matlab, not in folder mexfiles and yet the error message said "Invalid MEX-file 'd:\!mydocs\matlab\mexFiles\innerpart.mexw32': The specified procedure could not be found." So it knew it was supposed to be in folder mexfiles and it was indeed there. Is it lying when it said it could not find it?
I have innerpart.m but I also want a mex version. I next deleted innerpart.mexw32, the mex file version created with Matlab's compiler and reran. Innerpart.m warns you if you are not using the mex file.
EDU>> innerpart(1:3,1)
Warning: innerpart not using the mex file!
ans =
6
Let's try something else. Yesterday I installed Microsoft SDK 7.1. I ran mex -setup and selected SDK 7.1 as the compiler. This is what happened:
EDU>> mex innerpart.c
Creating library C:\Users\jwf10\AppData\Local\Temp\mex_f5RfPS\templib.x and object C:\Users\jwf10\AppData\Local\Temp\mex_f5RfPS\templib.exp
innerpart.obj : error LNK2019: unresolved external symbol _mxCreateDoubleMatrix_700 referenced in function _mexFunction
innerpart.mexw32 : fatal error LNK1120: 1 unresolved externals
D:\PROGRAM FILES (X86)\MATLAB\R2013A STUDENT\BIN\MEX.PL: Error: Link of 'innerpart.mexw32' failed.
This in interesting. SDK 7.1 fails to link because "unresolved external symbol _mxCreateDoubleMatrix_700" which is obviously a Matlab function. Does SDK 7.1 not use some matlab library?
Two questions:
1) The Matlab built in compiler seemed to compile and link innerpart.mexw32, but matlab could find it. Why? The execution said, "Invalid MEX-file 'd:\!mydocs\matlab\mexfiles\innerpart.mexw32'" It knew exactly where to look. Is it a lie and it could find it but this format does not work in Matlab 2013a?
2) Microsoft SDK 7.1 faild to link. Why couldn't it find the Matlab library?

Best Answer

  • .mex32 files would always be considered invalid if you were trying to use them from 64 bit MATLAB
  • a .mex32 file will be reported as invalid if it has a library dependency that it cannot fulfill, such as missing redistributable. Typically "Dependency Walker" is used to analyze that situation
I still do not know where _mxCreateDoubleMatrix_700 is from; I avoid booting MS Windows.