Thread Subject: Error from using dgecon of LAPACK and BLAS in R2009a

Subject: Error from using dgecon of LAPACK and BLAS in R2009a

From: Renwen Lin

Date: 5 Aug, 2009 07:08:01

Message: 1 of 7

I try to write down a mex file using and , in Matlab R2009a.
But get error LNK2019.
I have tried such codes in R2008b, there no such errors.
I am looking forward your help.

-----------------------My code---------------------------
#include "mex.h"
#include "matrix.h"
#include <stdlib.h>
#include "blas.h"
#include <math.h>
#include <string.h>

void dgetrf(const int *M, const int *N, double A[], const int *LDA,
int IPIV[], int *INFO);
void dgecon(const char *NORM, const int *N, const double A[],
const int *LDA, const double *ANORM, double *RCOND, double WORK[],
int IWORK[], int *INFO);
void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
{
   .. code that call dgetrf and dgecon
}

-----------------------My command in Matlab -----------------
mex ndbackslash.cpp "D:\Program Files\MATLAB\R2009a\extern\lib\win64\microsoft\libmwlapack.lib" "D:\Program Files\MATLAB\R2009a\extern\lib\win64\microsoft\libmwblas.lib"

-----------------------Debug errors -----------------
C:\USERS\ALIN\APPDATA\LOCAL\TEMP\MEX_O9~1\ndbackslash.obj D:\PROGRA~2\MATLAB\R2009A\EXTERN\LIB\WIN64\MICROS~1\libmwlapack.lib D:\PROGRA~2\MATLAB\R2009A\EXTERN\LIB\WIN64\MICROS~1\libmwblas.lib
   Creating library C:\USERS\ALIN\APPDATA\LOCAL\TEMP\MEX_O9~1\templib.x and object C:\USERS\ALIN\APPDATA\LOCAL\TEMP\MEX_O9~1\templib.exp
ndbackslash.obj : error LNK2019: unresolved external symbol "void __cdecl dgecon(char const *,int const *,double const * const,int const *,double const *,double *,double * const,int * const,int *)" (?dgecon@@YAXPEBDPEBHQEBN1PEBNPEANQEANQEAHPEAH@Z) referenced in function "void __cdecl compute_lu(double *,int,int *,double *,int *,int)" (?compute_lu@@YAXPEANHPEAH01H@Z)
ndbackslash.obj : error LNK2019: unresolved external symbol "void __cdecl dgetrf(int const *,int const *,double * const,int const *,int * const,int *)" (?dgetrf@@YAXPEBH0QEAN0QEAHPEAH@Z) referenced in function "void __cdecl compute_lu(double *,int,int *,double *,int *,int)" (?compute_lu@@YAXPEANHPEAH01H@Z)
ndbackslash.mexw64 : fatal error LNK1120: 2 unresolved externals

NB: error LNK2019: unresolved external symbol "void __cdecl dgecon

Subject: Error from using dgecon of LAPACK and BLAS in R2009a

From: Bruno Luong

Date: 5 Aug, 2009 10:25:03

Message: 2 of 7

"Renwen Lin" <linrenwen@gmail.com> wrote in message <h5bb4h$ee8$1@fred.mathworks.com>...
> I try to write down a mex file using and , in Matlab R2009a.
> But get error LNK2019.
> I have tried such codes in R2008b, there no such errors.
> I am looking forward your help.
>
> -----------------------My code---------------------------
> #include "mex.h"
> #include "matrix.h"
> #include <stdlib.h>
> #include "blas.h"
> #include <math.h>
> #include <string.h>
>
> void dgetrf(const int *M, const int *N, double A[], const int *LDA,
> int IPIV[], int *INFO);
> void dgecon(const char *NORM, const int *N, const double A[],
> const int *LDA, const double *ANORM, double *RCOND, double WORK[],
> int IWORK[], int *INFO);
> void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
> {
> .. code that call dgetrf and dgecon
> }
>
> -----------------------My command in Matlab -----------------
> mex ndbackslash.cpp "D:\Program Files\MATLAB\R2009a\extern\lib\win64\microsoft\libmwlapack.lib" "D:\Program Files\MATLAB\R2009a\extern\lib\win64\microsoft\libmwblas.lib"
>
> -----------------------Debug errors -----------------
> C:\USERS\ALIN\APPDATA\LOCAL\TEMP\MEX_O9~1\ndbackslash.obj D:\PROGRA~2\MATLAB\R2009A\EXTERN\LIB\WIN64\MICROS~1\libmwlapack.lib D:\PROGRA~2\MATLAB\R2009A\EXTERN\LIB\WIN64\MICROS~1\libmwblas.lib
> Creating library C:\USERS\ALIN\APPDATA\LOCAL\TEMP\MEX_O9~1\templib.x and object C:\USERS\ALIN\APPDATA\LOCAL\TEMP\MEX_O9~1\templib.exp
> ndbackslash.obj : error LNK2019: unresolved external symbol "void __cdecl dgecon(char const *,int const *,double const * const,int const *,double const *,double *,double * const,int * const,int *)" (?dgecon@@YAXPEBDPEBHQEBN1PEBNPEANQEANQEAHPEAH@Z) referenced in function "void __cdecl compute_lu(double *,int,int *,double *,int *,int)" (?compute_lu@@YAXPEANHPEAH01H@Z)
> ndbackslash.obj : error LNK2019: unresolved external symbol "void __cdecl dgetrf(int const *,int const *,double * const,int const *,int * const,int *)" (?dgetrf@@YAXPEBH0QEAN0QEAHPEAH@Z) referenced in function "void __cdecl compute_lu(double *,int,int *,double *,int *,int)" (?compute_lu@@YAXPEANHPEAH01H@Z)
> ndbackslash.mexw64 : fatal error LNK1120: 2 unresolved externals
>
> NB: error LNK2019: unresolved external symbol "void __cdecl dgecon

You probably have to use stdcall convention.

Bruno

Subject: Error from using dgecon of LAPACK and BLAS in R2009a

From: Renwen Lin

Date: 5 Aug, 2009 12:00:19

Message: 3 of 7

Bruno, Thanks so much,

After read few introductions of _stdcall. I think A __stdcall is supposed to deal with function's arguments, and I can not understood why it is needed here. It seems my problem is mex compile can not identify the function rather than its arguments.

Hope you can explain it a little more for me.


Lin Renwen

Subject: Error from using dgecon of LAPACK and BLAS in R2009a

From: Bruno Luong

Date: 5 Aug, 2009 12:29:02

Message: 4 of 7

"Renwen Lin" <linrenwen@gmail.com> wrote in message <h5bs8j$6pd$1@fred.mathworks.com>...
> Bruno, Thanks so much,
>
> After read few introductions of _stdcall. I think A __stdcall is supposed to deal with function's arguments, and I can not understood why it is needed here. It seems my problem is mex compile can not identify the function rather than its arguments.
>
> Hope you can explain it a little more for me.

The calling convention affects how arguments are put on the stack, but also have the function name are decorated and exported.

There is a tool to inspect what are the function names in a library. I can't recall it right now.

Bruno

Subject: Error from using dgecon of LAPACK and BLAS in R2009a

From: Steve Amphlett

Date: 5 Aug, 2009 13:39:02

Message: 5 of 7

"Bruno Luong" <b.luong@fogale.findmycountry> wrote in message <h5btue$rea$1@fred.mathworks.com>...
> "Renwen Lin" <linrenwen@gmail.com> wrote in message <h5bs8j$6pd$1@fred.mathworks.com>...
> > Bruno, Thanks so much,
> >
> > After read few introductions of _stdcall. I think A __stdcall is supposed to deal with function's arguments, and I can not understood why it is needed here. It seems my problem is mex compile can not identify the function rather than its arguments.
> >
> > Hope you can explain it a little more for me.
>
> The calling convention affects how arguments are put on the stack, but also have the function name are decorated and exported.
>
> There is a tool to inspect what are the function names in a library. I can't recall it right now.
>
> Bruno

Depends on the platform. For Windows it's "depends" for UNIX, "nm". Also bear in mind that the naming convention may dgecon_ a common way to mix C with FORTRAN.

Subject: Error from using dgecon of LAPACK and BLAS in R2009a

From: Renwen Lin

Date: 6 Aug, 2009 02:59:07

Message: 6 of 7

I have identify the problem.
My purpose is to solve X from A*X =B;

The first thing I need is LU decomposition of A.

Matlab use DGETRF caling DGECON for LU-decomposition in early version. But Use DGETRF calling DLACN2 in R2009a.

Thanks!

Lin Renwen

Subject: Error from using dgecon of LAPACK and BLAS in R2009a

From: Renwen Lin

Date: 6 Aug, 2009 08:17:02

Message: 7 of 7


Hi Bruno,

Thanks a lot :)

I think I understood some about your words.

and I find the functions in lib by checking <blas.h> in '\extern\include\' fileflip.

Lin Renwen

Tags for this Thread

Everyone's Tags:

Add a New Tag:

Separated by commas
Ex.: root locus, bode

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Tag Activity for This Thread
Tag Applied By Date/Time
mex lapack blas Renwen Lin 5 Aug, 2009 03:09:04
in r2009a error... Renwen Lin 5 Aug, 2009 03:09:04
rssFeed for this Thread
 

MATLAB Central Terms of Use

NOTICE: Any content you submit to MATLAB Central, including personal information, is not subject to the protections which may be afforded information collected under other sections of The MathWorks, Inc. Web site. You are entirely responsible for all content that you upload, post, e-mail, transmit or otherwise make available via MATLAB Central. The MathWorks does not control the content posted by visitors to MATLAB Central and, does not guarantee the accuracy, integrity, or quality of such content. Under no circumstances will The MathWorks be liable in any way for any content not authored by The MathWorks, or any loss or damage of any kind incurred as a result of the use of any content posted, e-mailed, transmitted or otherwise made available via MATLAB Central. Read the complete Terms prior to use.

Contact us at files@mathworks.com