I am having trouble writing a MEX file in MATLAB that can perform a simple linear operation such as taking the inverse of a matrix. I have successfully managed to take the inverse of a matrix using Visual Studio 2010 and have successfully created a MEX file hence the only thing I am having trouble is getting these two concepts together. I have tried to compile a MEX example code that I got from the MathWorks site but with no luck.
Here is what I have tried,
Saved the file (renamed it) I got from MathWorks as .c extension and then tried to compile it in MATLAB got:
Creating library C:\Users\CIT\AppData\Local\Temp\mex_bKHjrl\templib.x and object C:\Users\CIT\AppData\Local\Temp\mex_bKHjrl\templib.exp eko1.obj : error LNK2019: unresolved external symbol dgesv referenced in function mexFunction eko1.mexw64 : fatal error LNK1120: 1 unresolved externals
Also I tried to compile it as a .cpp file however an error occurred because it didnt recognize the memcpy function.
Since these didn't work I wrote my own program that used the subroutines dgetrf and dgetri from the LAPACK library however an error occured:
c:\users\cit\documents\matlab\f2c.h(16) : error C2371: 'complex' : redefinition; different basic types C:\Program Files\MATLAB\R2011b\extern\include\lapack.h(39) : see declaration of 'complex' c:\users\cit\documents\matlab\f2c.h(17) : error C2371: 'doublecomplex' : redefinition; different basic types C:\Program Files\MATLAB\R2011b\extern\include\lapack.h(40) : see declaration of 'doublecomplex' eko2.cpp(29) : error C2057: expected constant expression eko2.cpp(29) : error C2466: cannot allocate an array of constant size 0 eko2.cpp(29) : error C2133: 'ipiv' : unknown size eko2.cpp(33) : error C2664: 'dgetrf' : cannot convert parameter 1 from 'integer *' to 'ptrdiff_t *' Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast eko2.cpp(34) : error C2664: 'dgetri' : cannot convert parameter 1 from 'integer *' to 'ptrdiff_t *' Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
Any help you guys give me would be extremely appreciated
Thanks in advance.