Intel® oneAPI Math Kernel Library
Ask questions and share information with other developers who use Intel® Math Kernel Library.
7157 Discussions

how to use MKL in visual studio 2008(Fortran) ?

jiang_2009
Beginner
1,677 Views
hi
I updated my fortran compiler from compaq 6.0 to intel visual fortran 2008 11.0 recently.
and I encountered a problem using mkl in visual studio 2008. Those test codes which worked well in compaq 6.0 , however, couldn't find the .lib in 2008. I have alreay installed the mkl part to fortran folder, and added the directry.
tools-->option-->intel fortran->compiler-->include
$(IFortInstallDir)mkl\include
tools-->option-->intel fortran->compiler-->library
$(IFortInstallDir)mkl\ia64\lib
tools-->option-->intel fortran->compiler-->executables
$(IFortInstallDir)mkl\ia64\bin

is there anything else I'm missing?
even if I use the example files in the folder, it still can not find the link

here is the sample file:

* CGETRF (F07ARE) Example Program Text
* Mark 15 Release. NAG Copyright 1991.
* .. Parameters ..
INTEGER NIN, NOUT
PARAMETER (NIN=5,NOUT=6)
! INTEGER MMAX, NMAX, LDA
PARAMETER (MMAX=8,NMAX=8,LDA=MMAX)
* .. Local Scalars ..
INTEGER I, IFAIL, INFO, J, M, N
* .. Local Arrays ..
COMPLEX A(LDA,NMAX)
INTEGER IPIV(NMAX)
CHARACTER CLABS(1), RLABS(1)
* .. External Subroutines ..
EXTERNAL CGETRF, X04DBE
* .. Intrinsic Functions ..
INTRINSIC MIN
* .. Executable Statements ..
WRITE (NOUT,*) 'CGETRF Example Program Results'
* Skip heading in data file
READ (NIN,*)
READ (NIN,*) M, N
IF (M.LE.MMAX .AND. N.LE.NMAX) THEN
*
* Read A from data file
*
READ (NIN,*) ((A(I,J),J=1,N),I=1,M)
*
* Factorize A
*
CALL CGETRF(M,N,A,LDA,IPIV,INFO)
*
* Print details of factorization
*
WRITE (NOUT,*)
IFAIL = 0
CALL X04DBE('General',' ',M,N,A,LDA,'Bracketed','F7.4',
+ 'Details of factorization','Integer',RLABS,
+ 'Integer',CLABS,80,0,IFAIL)
*
* Print pivot indices
*
WRITE (NOUT,*)
WRITE (NOUT,*) 'IPIV'
WRITE (NOUT,99999) (IPIV(I),I=1,MIN(M,N))
*
IF (INFO.NE.0) WRITE (NOUT,*) 'The factor U is singular'
*
END IF
STOP
*
99999 FORMAT ((1X,I12,3I18))
END



it failes when building

Error 1 error LNK2019: unresolved external symbol CGETRF referenced in function MAIN__ cgetrfx.obj
Error 2 error LNK2019: unresolved external symbol X04DBE referenced in function MAIN__ cgetrfx.obj

thanks for help


0 Kudos
1 Solution
Gennady_F_Intel
Moderator
1,677 Views

I'd like to add two cents for tim18 commentsJ :

Please look at the KB article how Configuring Intel Fortran in Microsoft* Visual Studio* to build Intel MKL Applications

http://software.intel.com/en-us/articles/intel-math-kernel-library-intel-mkl-for-windows-build-intel-mkl-program-with-intel-fortran-in-microsoft-visual-studio/

--Gennady

View solution in original post

0 Kudos
8 Replies
TimP
Honored Contributor III
1,677 Views
If you're switching from CVF, you can't use the IA64 (Itanium) libraries. An 11.0 or 11.1 compiler installation of a compiler appropriate to your OS and hardware should automatically take care of selecting the correct MKL version, if you accepted the MKL option during installation.
If you are running a Windows X64 version, and have installed the Visual Studio C++ and X64 options, you would want the ifort Intel64 and the MKL which comes with it. If you are running 32-bit Windows, you must use the ifort ia32 and the MKL which that installation will suggest.
0 Kudos
Gennady_F_Intel
Moderator
1,678 Views

I'd like to add two cents for tim18 commentsJ :

Please look at the KB article how Configuring Intel Fortran in Microsoft* Visual Studio* to build Intel MKL Applications

http://software.intel.com/en-us/articles/intel-math-kernel-library-intel-mkl-for-windows-build-intel-mkl-program-with-intel-fortran-in-microsoft-visual-studio/

--Gennady

0 Kudos
jiang_2009
Beginner
1,677 Views
thanks, tim18 and Gennady Fedorov, both of your answers are very helpful.

I have one more question:
Is there anything I need to do if I try to run the application on anthor computor without installation of intel
Fortran in Microsoft Visual Studio?
I copied&clicked the .exe file directly and was told to missing some .dll filesmkl_intel_thread.dll. even if I copied those files, it will keep telling me there are some other .dll files missing and so...-_-



I'd like to add two cents for tim18 commentsJ :

Please look at the KB article how Configuring Intel Fortran in Microsoft* Visual Studio* to build Intel MKL Applications

http://software.intel.com/en-us/articles/intel-math-kernel-library-intel-mkl-for-windows-build-intel-mkl-program-with-intel-fortran-in-microsoft-visual-studio/

--Gennady


0 Kudos
ArturGuzik
Valued Contributor I
1,677 Views
Quoting - jiang_2009

Hi,

you need to copy Intel VF redistributable dll(s). Please note that debug libraries are NOT redistributable. The list is in redist.txt in the doc folder. You'll also need run-time libraries from VC (if the target machine doesn't have them already installled). For that one you can get self-extracting package from MS webpage. You can use Dependency Walker to verify the dependencies of your exe file.

A.
0 Kudos
jiang_2009
Beginner
1,677 Views
Quoting - ArturGuzik
Hi,

you need to copy Intel VF redistributable dll(s). Please note that debug libraries are NOT redistributable. The list is in redist.txt in the doc folder. You'll also need run-time libraries from VC (if the target machine doesn't have them already installled). For that one you can get self-extracting package from MS webpage. You can use Dependency Walker to verify the dependencies of your exe file.


Hi,
thanks for your reply. Do you mean I have to copy all those .dll files listed in redist.txt, or, at least verified by Dependency walker, to the same directory of application? Could I just produce an application .exe file which can run without those .dll just like compaq visual Fortran did? thanks agian~
0 Kudos
TimP
Honored Contributor III
1,677 Views
Quoting - jiang_2009
Do you mean I have to copy all those .dll files listed in redist.txt, or, at least verified by Dependency walker, to the same directory of application? Could I just produce an application .exe file which can run without those .dll just like compaq visual Fortran did?
If you are interested in the static link options, look up the static-intel and openmp-link options in the ifort docs, I believe you must specify the static MKL libraries in your library dependencies, if you want those. Likewise, you may be interested in Microsoft options for Visual Studio static libraries.
It's difficult/inadvisable to use static libraries with .dll's which you build. Otherwise, the static link includes the necessary library functions in your .exe, making it larger, but avoiding the redistributable libraries.
0 Kudos
ArturGuzik
Valued Contributor I
1,677 Views
Quoting - jiang_2009
Could I just produce an application .exe file which can run without those .dll just like compaq visual Fortran did? thanks agian~

More or less. I mean, follow Tim's reply and:

(1) set Multithreaded in Runtime libraries (I think it's default in IVF in VS)
(2) specify static MKL libs (in linking line in VS) but use libiomp5md.lib and other non-static threading libs, as MKL suggests. This will save you from many problems with OpenMP and other threading problems
(3) get VC run-time redistributable package.
(4) check with Dependency Walker whether you need anything else.

Equipped with that you should easily redistribute your exe. Obviously you need to provide only what you need. Redist.txt lists all libraries which you're allowed to distribute within license you purchased with compiler. Once VC is installed, you usually copy .exe libmmd.lib and libiomp5md.dll with new version(s) of your program. Nothing more.

The procedure was quite the same for Compaq. The difference was that the redistributable Fortran package was provided (which copied VC and core libs, so you didn't see/copy dlls) and there was less libs regarding multi-threading and OpenMP support.

A.
0 Kudos
jiang_2009
Beginner
1,677 Views
Quoting - ArturGuzik
thx~
I find the correct static MKL libs
Sincerely

Jiang


More or less. I mean, follow Tim's reply and:

(1) set Multithreaded in Runtime libraries (I think it's default in IVF in VS)
(2) specify static MKL libs (in linking line in VS) but use libiomp5md.lib and other non-static threading libs, as MKL suggests. This will save you from many problems with OpenMP and other threading problems
(3) get VC run-time redistributable package.
(4) check with Dependency Walker whether you need anything else.

Equipped with that you should easily redistribute your exe. Obviously you need to provide only what you need. Redist.txt lists all libraries which you're allowed to distribute within license you purchased with compiler. Once VC is installed, you usually copy .exe libmmd.lib and libiomp5md.dll with new version(s) of your program. Nothing more.

The procedure was quite the same for Compaq. The difference was that the redistributable Fortran package was provided (which copied VC and core libs, so you didn't see/copy dlls) and there was less libs regarding multi-threading and OpenMP support.

A.

0 Kudos
Reply