The LAPACK forum has moved to https://github.com/Reference-LAPACK/lapack/discussions.

Linking LAPACK with Visual Studio

Open discussion regarding features, bugs, issues, vendors, etc.

Linking LAPACK with Visual Studio

Postby owoodford » Fri Nov 27, 2009 6:17 am

Hi

I've downloaded LAPACK for Windows. Now I'm trying to link the provided LAPACK libraries to my application (a MATLAB dll), to no avail. The compiler/linker suite I'm using is Microsoft Visual Studio 2008 Express Edition. My OS is Windows Vista.

I have the options -llapack and -lblas set, and the linker definitely finds the libraries (it was complaining before I pointed the linker to the correct directory). Now I get the following errors:

sba_lapack.obj : error LNK2019: unresolved external symbol _dtrtrs_ referenced in function _sba_Axb_QR
sba_lapack.obj : error LNK2019: unresolved external symbol _dorgqr_ referenced in function _sba_Axb_QR
sba_lapack.obj : error LNK2019: unresolved external symbol _dgeqrf_ referenced in function _sba_Axb_QR
sba_lapack.obj : error LNK2019: unresolved external symbol _dpotrs_ referenced in function _sba_Axb_Chol
sba_lapack.obj : error LNK2019: unresolved external symbol _dpotrf_ referenced in function _sba_Axb_Chol

etc.

I think it's because the compiler is adding the preceding underscore to the function name. However, I can't find an option to stop it from doing this.

If anyone knows how to solve this please let me know.

Regards,
Oliver
owoodford
 
Posts: 1
Joined: Fri Nov 27, 2009 6:07 am

Re: Linking LAPACK with Visual Studio

Postby gorcee » Tue Dec 01, 2009 2:02 pm

It's not due to the prepended underscores, that's just how it comes out.

It looks like you're not linking to one of the libraries, though I'm not sure which. All of those libraries are LAPACK routines, as opposed to BLAS or F2C.

Under visual studio, you can add a project to your solution and VS will compile the source in that project. The CLAPACK visual studio download has a .vcproj file that should serve this purpose.

Alternatively, you could manually add the LAPACK source files that you want to use, which is tedious but it definitely works.
gorcee
 
Posts: 7
Joined: Mon Nov 30, 2009 1:14 pm

Re: Linking LAPACK with Visual Studio

Postby ctangctang » Mon Jan 11, 2010 9:44 pm

I have a similar problem. I have a little C++ program with the following lines of code:

extern "C" void dgesv_(const int *N, const int *nrhs, double *A, const int *lda, int* ipiv, double *b, const int *ldb, int *info);

In the main function, I call dgesv_. I linked my program to the precompiled libraries blas.lib and lapack.lib that I had downloaded from the LAPACK for Windows website, but I got the following error:

error LNK2001: unresolved external symbol _dgesv_

Anyone knows what caused the error and how to fix it?

Thanks.
ctangctang
 
Posts: 1
Joined: Mon Jan 11, 2010 9:18 pm

Re: Linking LAPACK with Visual Studio

Postby shak_sharf » Mon Mar 01, 2010 10:43 am

Hi Oliver,
The errors you get due to the variable names getting prefixed with underscores are due to Name mangling in Visual Studio. Look at the following link for more info.
http://en.wikipedia.org/wiki/Microsoft_ ... e_Mangling

More info on the solution can be found in this forum discussion.

http://www.codeguru.com/forum/archive/i ... 68937.html
shak_sharf
 
Posts: 1
Joined: Mon Mar 01, 2010 10:36 am


Return to User Discussion

Who is online

Users browsing this forum: No registered users and 6 guests