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

2 visualizzazioni (ultimi 30 giorni)
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?

Risposta accettata

Walter Roberson
Walter Roberson il 20 Mar 2016
  • .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.
  2 Commenti
John Fox
John Fox il 21 Mar 2016
You said, "mex32 files would always be considered invalid if you were trying to use them from 64 bit MATLAB"
I am not using 64 bit Matlab. I am using 32 bit Matlab. That is why Matlab's compiler created mexw32. So I still do not understand why Matlab can not find mexw32 when I compile using Matlab's compiler. Any ideas?
I tried running Dependency Walker. When I opened matlab.exe it had about 300 "Error opening file. The system can not find the file specified."
You did not explain why compiling with Microsoft SDK 7.1 gave a linker error. But since you hate windows I guess you do not know.
Walter Roberson
Walter Roberson il 21 Mar 2016
Every time I boot Windows it takes me about two hours to install the Microsoft updates and bring the anti-virus up to date and upgrade the drivers (it loses the HMI drivers constantly) and rescan for security vulnerabilities—all pure overhead just to make the system reasonably stable and marginally secure so that the first electronic woodpecker that comes along does not destroy civilization. And then I can start to do whatever I booted into Windows to do. Typically that is to log in to my mother's computer and spend the following 2 1/2 hours updating and securing her system.
MS Windows frustrates me and wastes my time. I avoid booting it,the way you probably avoid doing a real cleaning of your refrigerator and freezer. I don't hate it, but I am certainly not going to jump in and spend the next several hours booting and upgrading and researching discussion boards and testing of software just to answer your question. I will leave that to someone who runs Windows routinely.

Accedi per commentare.

Più risposte (0)

Categorie

Scopri di più su C Shared Library Integration in Help Center e File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by