Lapack Linking Problem, Visual Studio, 64-bit

Post here if you have a question about linking your program with LAPACK or ScaLAPACK library

Lapack Linking Problem, Visual Studio, 64-bit

Postby gboyinfinity » Sun Jan 03, 2016 10:15 pm

I'm running into a problem that tracks with a previous post at viewtopic.php?f=12&t=4260
I'm using the directions referenced there: with little success.

Summary of what I'm trying to do:
    Get Lapack up and running in support of 64-bit C++ software I'm writing in Visual Studio 2013.
    I'm using the pre-built libraries that are given there at ... #libraries by downloading x64.dll & x64.lib for Ref BLAS, LAPACK & LAPACKE. (I'm also downloading the 4 LAPACKE headers that are there <= but I think these are not critical for this 1st project I'm trying to run). I put these library files in appropriate lib, bin, and include folders.

Visual Studio steps I'm taking:
    I start a new project - picking the Visual C++ Empty Project template
    In project properties, I first go to Configuration Manager and create a new solution platform of x64 (copying the Win32 settings)
    Then for all configurations and for all platforms I point the Linker Additional Library Dependencies to where I put the prebuilt *.lib files. I also add to the Linker => Input the libblas.lib and liblapack.lib libraries
    Note 1: I'm not adding any of the Lapacke stuff yet since I don't believe the simple example program I'm trying to run will need that stuff (and adding those paths did not seem to help in earlier attempts.)
    Note 2: I know that the libraries I downloaded are 64-bit only - but I applied these project properties to 'all platforms' (meaning including the 32-bit platform) to demonstrate something, below...
    Then in Visual Studio, I added a single C++ source file 'source.cpp' with the code provided at
    I added the 'extern "C" ' text before the two Lapack prototypes (for dgesv_ & dgels_)
    And then I try to compile this program (in either Debug or Release configuration) - for an x64 platform and get the error:
Code: Select all
error LNK2019: unresolved external symbol dgesv_ referenced in function main

which seems to indicate that the prebuilt libraries do not contain these functions.

The very odd thing is that if I change the platform to 'win32', the project compiles! (huh?)

Btw, adding an underscore before dgesv_ in the code also does not seem to work - giving me the error upon compilation:
Code: Select all
fatal error LNK1112: module machine type 'X86' conflicts with target machine type 'x64'

which also tracks with some of the discussion at viewtopic.php?f=12&t=4260

Again, this all seems to track the discussion at viewtopic.php?f=12&t=4260 and folks there seemed to indicate that building the libraries yourself with CMAKE is a solution (I'm trying that but running into issues there with it not finding the proper fortran compiler <= that's probably appropriate for a different post!). More importantly, in the last post of that thread, 'admin' indicated that they corrected any previous problem with these pre-built libaries and that they should work now. So I must be doing something incorrect, right? Does anyone see a problem in the workflow I'm using here?
Posts: 5
Joined: Sun Jan 03, 2016 12:40 pm

Re: test

Postby admin » Mon Jan 04, 2016 9:59 pm

Unfortunately, I am building the library on a older platform than you, so there is always the possibility of compatibility issue.
Regarding the x64 build, it seems I am doing something wrong when I generate those libraries.

Indeed, build the library yourself is the best solution.

not finding the proper fortran compiler

It looks like a step 4 issue from ( ... index.html)
Make sure you reopen CMAKE after adding your Environment Variable

Hope it helps
Site Admin
Posts: 608
Joined: Wed Dec 08, 2004 7:07 pm

Re: Lapack Linking Problem, Visual Studio, 64-bit

Postby gboyinfinity » Tue Jan 05, 2016 10:50 am

Hi Julie,

Thanks for the post. I am now trying to build lapack using CMake but continue to have problems with the fortran compiler I'm specifying. I think I'll describe my saga in a separate post as it may make it easier for others to find in the future...
Posts: 5
Joined: Sun Jan 03, 2016 12:40 pm

Re: Lapack Linking Problem, Visual Studio, 64-bit

Postby gboyinfinity » Tue Jan 05, 2016 2:07 pm

Btw, the aforementioned post is at viewtopic.php?f=12&t=4875&p=11710#p11710. It describes the steps I took to use CMake to generate the Lapack libraries on my system. I was having a problem with how I was using CMake, but corrected my error and it works now. See that post for the details.
Posts: 5
Joined: Sun Jan 03, 2016 12:40 pm

Return to Linking Problem

Who is online

Users browsing this forum: Yahoo [Bot] and 1 guest