- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello,
I'm a very basic user of Visual Fortran.
I have a simple Fortran program which I'm trying to run:
PROGRAM matrixinv IMPLICIT NONE REAL(8),DIMENSION(3,3)::A,C INTEGER(4),DIMENSION(3)::IPVT REAL(8)::RCOND REAL(8),DIMENSION(3)::V,B A(1,1)=3.0_8 A(1,2)=2.0_8 A(1,3)=-1.0_8 A(2,1)=2.0_8 A(2,2)=-2.0_8 A(2,3)=4.0_8 A(3,1)=-1.0_8 A(3,2)=0.5_8 A(3,3)=-1.0_8 B(1)=1.0_8 B(2)=-2.0_8 B(3)=0.0_8 call gesv(A,B) PRINT*,B END PROGRAM matrixinv
This program uses gesv from MKL.
My problem is not being able to link to MKL.
Online instructions tell me to go to Project-> properties -> Fortran -> Libraries -> Use Intel Math Kernel Library -> Sequential (for example).
I do that but I still get: Severity Code Description Project File Line Suppression State
Error error LNK2019: unresolved external symbol GESV referenced in function MAIN__ Combined_Main.obj
Why won't the program recognize MKL?
Thank you.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
In VS 2017, the list of additional libraries (mkl_blas95_lp64.lib mkl_lapack95_lp64.lib mkl_intel_lp64.lib mkl_sequential.lib
) should be inserted into the lower rectangle under Project Properties -> Configuration Properties -> Linker -> Command Line -> Additional Options.
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The approach that you have tried is sufficient for Fortran-77 calls, but not for Fortran-95+ calls.
If you wish to call MKL or other subroutines/functions that take optional arguments, have generic names with arguments of different types, etc., you must provide USE statements or interface blocks in your source files and specify that the corresponding BLAS-95 and Lapack-95 libraries be searched at link time. See https://software.intel.com/en-us/forums/intel-math-kernel-library/topic/301587 for a related discussion, and use the MKL Link Line advisor https://software.intel.com/en-us/articles/intel-mkl-link-line-advisor to configure the command lines for compiling and linking.
Posts on this topic are better served in the MKL forum, https://software.intel.com/en-us/forums/intel-math-kernel-library .
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I used the link advisor and got this:
mkl_blas95_lp64.lib mkl_lapack95_lp64.lib mkl_intel_lp64.lib mkl_sequential.lib mkl_core.lib
Now what do I do with this line?
Thank you.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Add "Use Lapack95" to your source, between the Program line and the IMPLICIT line. Open the command window for Intel Fortran for 64-bit targets from the Start menu. Compile using
ifort /Qmkl Combined_Main.f90 mkl_blas95_lp64.lib mkl_lapack95_lp64.lib mkl_intel_lp64.lib mkl_sequential.lib mkl_core.lib
Alternatively, if you are using Visual Studio, first make sure that the project is configured to use MKL (you have probably done this already). Then, select the project Properties pane, add the list of libraries that you obtained from the MKL Advisor to Configuration Properties - Command Line - Additional Options, and check that the target is set to X64. Press OK, and then select Build.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
It doesn't work. I still get "unresolved external symbol GESV"
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Please describe the steps that you tried.
If you have not done so already, you may need to do "Clean" and then "Build" from Visual Studio.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
You did not add the USE statement to your source, as advised in #4 and for the reasons stated in #2.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
This is the updated code. Still gives me the error. Do I need to add the advisor line: "mkl_blas95_lp64.lib mkl_lapack95_lp64.lib mkl_intel_lp64.lib mkl_sequential.lib mkl_core.lib" Only to the properties->Fortran->command line or is there another place I need to put it? There are command line options in other "properties" menus like "Linker", "Resources", etc. PROGRAM matrixinv Use Lapack95 implicit none REAL(8),DIMENSION(3,3)::A,C INTEGER(4),DIMENSION(3)::IPVT REAL(8)::RCOND REAL(8),DIMENSION(3)::V,B A(1,1)=3.0_8 A(1,2)=2.0_8 A(1,3)=-1.0_8 A(2,1)=2.0_8 A(2,2)=-2.0_8 A(2,3)=4.0_8 A(3,1)=-1.0_8 A(3,2)=0.5_8 A(3,3)=-1.0_8 B(1)=1.0_8 B(2)=-2.0_8 B(3)=0.0_8 call gesv(A,B) PRINT*,B END PROGRAM matrixinv
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
There are many places to change settings in Visual Studio, and from your posts I cannot see which setting was set incorrectly. The "/c" in the command line in Capture2.jpg should not be there, since it tells the compiler to stop after compiling.
The most straightforward approach at this point, considering that you have a single short source file, is to open an Ifort-x64 command window, and build there using the command line of #4.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
It's very frustrating. My question is so simple and straightforwrd and I'm sure thousands of people use MKL each day. Why did they make it so difficult...
Where can I find the command window to try and compile from there?
Another question: Would it be a good idea to uninstall and reinstall the Intel Fortran? Could that solve the problem?
Thank you for your help.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
hollander, yair wrote:It's very frustrating. My question is so simple and straightforward and I'm sure thousands of people use MKL each day. Why did they make it so difficult...
My personal opinions: Intel is not to be blamed; the simple command line approach is completely adequate, but customers seem to prefer to live inside Visual Studio, despite the cost of doing so. VS is a complex MS product with many bells, whistles and knobs. It may work well for large projects. For simple single-file builds, such as yours, it is not only an overkill, it can be a source of much frustration. However, once you get the hang of it, VS can be a useful, if not pleasant, tool to use.
hollander, yair wrote:
Where can I find the command window to try and compile from there?
Windows Start Menu-> Intel Parallel Studio yyyy -> Compiler and Performance Libraries -> Command Prompt with .... -> ... for Intel 64 ...
The exact titles depend on the version of Intel Fortran that you have.
hollander, yair wrote:
Another question: Would it be a good idea to uninstall and reinstall the Intel Fortran? Could that solve the problem?
NO! There is nothing that I have seen to indicate that there is any problem with your installation. It takes many hours to do a complete installation, so do not do that unless it is really necessary.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Please create a ZIP file of your entire VS project and attach it to a reply here. Screenshots are not useful.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
In VS 2017, the list of additional libraries (mkl_blas95_lp64.lib mkl_lapack95_lp64.lib mkl_intel_lp64.lib mkl_sequential.lib
) should be inserted into the lower rectangle under Project Properties -> Configuration Properties -> Linker -> Command Line -> Additional Options.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
mecej4, I'm sending you kisses. It works now !!!!!!!
Steve, you would have probably figured the solution in a minute. Thank you as well.
:-)
I'm happy again.

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page