Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.

Running LAPACK

Geoffrey_P_
Beginner
4,434 Views

I want to get LAPACK running with Intel Fortran using Visual Studio to develop fortran applications. I am unable to link to LAPACK libraries when I write Fortran code. I wrote a simple progran that calls the LAPACK routine dgemsv, and I have used the project properties to specify lapack libraries locations and lib names. I get error 11018 twice and fatal link error LNK1181. I searched the web for a solution, and found that I should run CMAKE. This software gives error "Package 'IFLangServicePackage' failed to load". These cryptic solutions with no one to help when there are errors are useless. Could someone please tell me how to link to the lapack libraries using intel fortran in visual studio 2013?

0 Kudos
15 Replies
Steven_L_Intel1
Employee
4,434 Views

CMAKE is not relevant - ignore it.

Please attach a zip of the buildlog.htm from the original attempt to build. You have not shown enough information to help you (message numbers alone are insufficient.)

Are you using the LAPACK supplied by Intel Math Kernel Library? If not, you should be.

0 Kudos
mecej4
Honored Contributor III
4,434 Views

Did you build the Lapack library from sources? Or did you download a prebuilt Lapack from, say, Netlib? As Steve said, you could simply use the MKL libraries that are included with Parallel Studio. MKL contains all of Lapack 3.5, BLAS, and more. In the project properties, simply set the option to use MKL, or use the /Qmkl compiler option if building at the command line.

0 Kudos
Geoffrey_P_
Beginner
4,434 Views

I do not need Intel Math Kernal Library at $699. Way too expensive.

I have something running for now. I compiled all the lapack fortran source into a library and linked to it. However, the creation of the library was brutal because there were hundreds of errors in the initial compile. I had to remove dozens of files that created errors from the list by hand in Visual Studio. That leaves me with an incomplete lapack library, but at least the routines I need for now are in there. Maybe I will never need them, but somehow I doubt it.

The libraries that came precompiled in lapack worked when linked to a C++ program, but give the 11018 errors and fatal link error LNK1181 when linked to an Intel fortran program.

0 Kudos
TimP
Honored Contributor III
4,434 Views

MKL is included in the base price and all distributed versions of Intel Fortran.  The Community version is available for free separately.

Using MKL is a lot easier than paying attention to the options needed to compile the open source lapack correctly.

I don't see how you can expect anyone to guess where you got lapack, or why it would be worth the attention of this forum, if you don't use the one supplied with the compiler or specify whether you used the source from netlib.org.

0 Kudos
Geoffrey_P_
Beginner
4,434 Views

If MKL is in all distributed versions of Intel Fortran, how do I link to it?

0 Kudos
Steven_L_Intel1
Employee
4,434 Views

Again, please attach a zip of the buildlog.htm so we can see exactly what is going wrong and be able to help you.

As Tim says, there is no extra charge to use MKL, it's already on your system if you installed Intel Fortran. MKL also has the advantage of being highly optimized and parallelized.

0 Kudos
Geoffrey_P_
Beginner
4,434 Views
I've attached the zip, but here it is.

Compiling with Intel(R) Visual Fortran Compiler 16.0 [IA-32]...
ifort /nologo /debug:full /Od /warn:interfaces /module:"Debug\\" /object:"Debug\\" /Fd"Debug\vc120.pdb" /traceback /check:bounds /check:stack /libs:dll /threads /dbglibs /c /Qlocation,link,"C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\\bin" "C:\VC++Projects\Console2\Console2\Console2.f90"
Linking...
Link /OUT:"Debug\Console2.exe" /INCREMENTAL:NO /NOLOGO /MANIFEST /MANIFESTFILE:"Debug\Console2.exe.intermediate.manifest" /MANIFESTUAC:"level='asInvoker' uiAccess='false'" /DEBUG /PDB:"C:\VC++Projects\Console2\Console2\Debug\Console2.pdb" /SUBSYSTEM:CONSOLE /IMPLIB:"C:\VC++Projects\Console2\Console2\Debug\Console2.lib" "Debug\Console2.obj"
Console2.obj : error LNK2019: unresolved external symbol _DGESV referenced in function _MAIN__
Debug\Console2.exe : fatal error LNK1120: 1 unresolved externals


Console2 - 2 error(s), 0 warning(s)

 

Here's the code:

    program Console2

    IMPLICIT REAL*8(A-H,O-Z)    
    Dimension A(2,2), V(2), R(2), IPIV(2)

    A(1,1) = 5.
    A(2,1) = 6.
    A(1,2) = 4.
    A(2,2) = 8.
    
    V(1) = 50.
    V(2) = 33.
    
    call dgesv(2, 1, A, 2, IPIV, V, 2, INFO)

    end program Console2

 

0 Kudos
mecej4
Honored Contributor III
4,434 Views

All that you need to do is to tell the compiler to use the MKL library when linking. Or you could specify that the Lapack library that you built should be used during linking. If you do neither, since Lapack and BLAS are not part of Fortran, you will get linker errors.

Either select the option to link with the MKL libraries in the Visual Studio project properties, or specify the /Qmkl option. That is all.

0 Kudos
Geoffrey_P_
Beginner
4,434 Views

So, I go to Project/Console02 Properties/Linker. Then what? There is no MKL option.

0 Kudos
mecej4
Honored Contributor III
4,434 Views

If you have just created a new Fortran console application project, right click on the project in the Solution Explorer window of VS. Select the active configuration, then Fortran and then Libraries. The fourth selection in the right side pane is "Select Intel Math Kernel Library". Set that to "yes". 

0 Kudos
Steven_L_Intel1
Employee
4,434 Views

I see this is a different issue than you originally described. mecej4 has the right answer for this - you tell Fortran that you want to use MKL and that should take care of it.

0 Kudos
Geoffrey_P_
Beginner
4,434 Views

Image2.jpg

Steve, my original question was "Could someone please tell me how to link to the lapack libraries using intel fortran in visual studio 2013?" This is the issue I have been trying to solve all along. Now I am finding out that I apparently have MKL which has lapack imbedded. We are finally getting to the solution to the original question.

However, mecej4 has not yet presented the answer. When I right click on the Solution Explorer, I get the menuabove. The current configuration is "debug" but there is no 4th selection, nor do the two options presented ("start new instance" and "step into new instance") allow anything like what mecej4 describes.

0 Kudos
Geoffrey_P_
Beginner
4,434 Views

So what mecej4 means is to right click and choose "properties". Then choose "Fortran" them "libraries" I was looking under "linker".

0 Kudos
Steven_L_Intel1
Employee
4,434 Views

On that menu, select Properties. Then you can go to Fortran > Libraries. 

0 Kudos
mecej4
Honored Contributor III
4,434 Views

A few lines to clarify some of the points raised in this thread.

Most of the time, using the MKL libraries, which come with the compiler, is sufficient to support to calls to Lapack and BLAS routines. If you wish to use some of the newer routines that are present in Lapack 3.6 but not in Lapack 3.5 (which is the version that MKL matches), or if you wish to build Lapack 3.6 libraries using IFort, the process is quite simple, and does not require Cmake or even GNU make. 

1. Obtain and unpack the Lapack 3.6 source distribution from Netlib (http://www.netlib.org/lapack/lapack-3.6.0.tgz). Change to the main Lapack directory, "...\lapack-3.6.0" from an IFort command window.

2. Copy the file make.inc.example to make.inc, and edit the latter, commenting out "TIMER = INT_ETIME" and uncommenting "TIMER = INT_CPU_TIME. Replace "gfortran" by "ifort" in the lines with FORTRAN = and LOADER=. Edit the line with OPTS = to insert your desired options, such as -O2.

3. Change to the SRC directory and, if you have GNU make, just type "make". If you wish to use the MS tool nmake instead, edit the makefile and change "ifdef" to "!ifdef" and "endif" to "!endif" throughout. Then, use the command "nmake".

4. After the build finishes, you will find the newly built static library, "liblapack.a", in the parent directory. Rename it to lapack36.lib or some such name for use with Ifort.

If you wish to build a DLL, you can do so starting with the static library using standard methods. For example, you can use dumpbin or nm to create a .DEF file of exported routine names and build a DLL in the usual way.

0 Kudos
Reply