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

Linking MKL is very hard - can't link using Visual Studio

Rodney_H_
Beginner
1,052 Views

Visual Studio 2012, Parallel Studio XE 2013, 64-bit Win7. C++ console project, Intel c++13.0 compiler, attempting to compile 64-bit (but same errors occur with 32 bit). Started VS from /start/all programs/Parallel Studio XE 2013/Parallel Studio XE 2013 with VS2012

Trying to run one of the examples, cblas_dgemvx to assess MKL for my project. I need to do very fast matrix-vector operations.

The c file builds but link fails.

Settings are :

Intel performance libraries - Use MKL - sequential, Use ILP64 - yes

Includes:

C:\Program Files (x86)\Intel\Composer XE 2013\mkl\include

Libs:

 C:\Program Files (x86)\Intel\Composer XE 2013\compiler\lib\intel64

C:\Program Files (x86)\Intel\Composer XE 2013\mkl\lib\intel64

Command line additional options for compiler :  /DMKL_ILP64  -I%MKLROOT%/include /Qmkl

Linker inputs (used link line adviser).

mkl_intel_ilp64.lib mkl_sequential.lib mkl_core.lib

no linker command line options.

I followed the instructions in MKL11 docs, "Creating, Configuring, and Running the Intel® C/C++ and/or Visual C++* 2008 Project"

They're out of date but easily modified for VS2012.

Build output appears below. What else do I need to do ? Shouldn't be this hard. The compiler works for non-MKL projects.

 

1>------ Build started: Project: MKL_CBLAS (Intel C++ 13.0), Configuration: Release x64 ------

1>ipo : warning #11021: unresolved PrintVectorD

1>          Referenced in ipo_6504obj3.obj

1>ipo : warning #11021: unresolved PrintArrayD

1>          Referenced in ipo_6504obj3.obj

1>ipo : warning #11021: unresolved PrintParameters

1>          Referenced in ipo_6504obj3.obj

1>ipo : warning #11021: unresolved GetArrayD

1>          Referenced in ipo_6504obj3.obj

1>ipo : warning #11021: unresolved GetVectorD

1>          Referenced in ipo_6504obj3.obj

1>ipo : warning #11021: unresolved GetCblasCharParameters

1>          Referenced in ipo_6504obj3.obj

1>ipo : warning #11021: unresolved GetScalarsD

1>          Referenced in ipo_6504obj3.obj

1>ipo : warning #11021: unresolved GetIntegerParameters

1>          Referenced in ipo_6504obj3.obj

1>ipo : error #11023: Not all components required for linking are present on command line

1>  xilink: executing 'link'

1>ipo_6504obj3.obj : error LNK2019: unresolved external symbol GetIntegerParameters referenced in function main

1>ipo_6504obj3.obj : error LNK2019: unresolved external symbol GetScalarsD referenced in function main

1>ipo_6504obj3.obj : error LNK2019: unresolved external symbol GetCblasCharParameters referenced in function main

1>ipo_6504obj3.obj : error LNK2019: unresolved external symbol GetVectorD referenced in function main

1>ipo_6504obj3.obj : error LNK2019: unresolved external symbol GetArrayD referenced in function main

1>ipo_6504obj3.obj : error LNK2019: unresolved external symbol PrintParameters referenced in function main

1>ipo_6504obj3.obj : error LNK2019: unresolved external symbol PrintVectorD referenced in function main

1>ipo_6504obj3.obj : error LNK2019: unresolved external symbol PrintArrayD referenced in function main

1>C:\Users\Rodney\Documents\Visual Studio 2012\Projects\MKL_CBLAS\x64\Release\MKL_CBLAS.exe : fatal error LNK1120: 8 unresolved externals

========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

 

 

 

 

0 Kudos
6 Replies
mecej4
Honored Contributor III
1,052 Views

Add common_func.c in the ...\mkl\examples\cblas directory to your project.

0 Kudos
Rodney_H_
Beginner
1,052 Views

Thanks a lot! I'm just trying to get started and it seemed to be a link configuraiton issue.

0 Kudos
satyamahesh_m_
Beginner
1,052 Views

1>------ Build started: Project: sparsehair, Configuration: Release Win32 ------
1>  svdPower.cpp
1>main.obj : error LNK2001: unresolved external symbol _f2c_dgemv
1>main.obj : error LNK2001: unresolved external symbol _f2c_idamax
1>main.obj : error LNK2001: unresolved external symbol _f2c_dtrsv
1>main.obj : error LNK2001: unresolved external symbol _f2c_dcopy
1>main.obj : error LNK2001: unresolved external symbol _f2c_dnrm2
1>main.obj : error LNK2001: unresolved external symbol _f2c_dscal
1>main.obj : error LNK2001: unresolved external symbol _idamin_
1>main.obj : error LNK2001: unresolved external symbol _f2c_ddot
1>svdPower.obj : error LNK2001: unresolved external symbol _cblas_ddot
1>svdPower.obj : error LNK2001: unresolved external symbol _cblas_dcopy
1>svdPower.obj : error LNK2001: unresolved external symbol _cblas_dgemv
1>svdPower.obj : error LNK2001: unresolved external symbol _cblas_dscal
1>svdPower.obj : error LNK2001: unresolved external symbol _cblas_dnrm2
1>C:\Users\satyamahesh\Documents\Visual Studio 2013\Projects\sparsehair\Release\sparsehair.exe : fatal error LNK1120: 13 unresolved externals
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

how to solve this linking erros.. i am struggling with this linking erros. 

 

i inlcuded the lib files like mkl_blas95_ilp64.lib and mkl_lapack95_ilp64.lib but still i am getting the errors.. 

 

pls someone can suggest if i miss to add something in it.. to solve it

0 Kudos
Zhen_Z_Intel
Employee
1,052 Views

Hi satyamahesh,

  • The error "unresolved external symbol _f2c_dgemv" reflects the f2c lib cannot be recognized. The Intel MKL doesn't contain f2c library, it belongs to Netlib. The f2c lib is used to transfer Fortran to C program. The MKL could support C program, it is unnecessary to use f2c.
  • The error "LNK2001: unresolved external symbol _cblas_ddot" reflects you didn't add MKL lib to your application. You can try, right click your project, select properties->Intel Performance Lib->Use Intel MKL.
  • It seems your application doesn't need the F95 libs, please remove the link of mkl_blas95_ilp64.lib and mkl_lapack95_ilp64.lib.

Hope it could help you, if the problem still cannot be solved, please send source code of your project to us.

Best regards,

Fiona

0 Kudos
mecej4
Honored Contributor III
1,052 Views

In #4 we see a list of linker error messages, but no description is given regarding what the sources contain and what compiling and linking commands were used. Here are a few points to consider:

  • Does your code contain Fortran 95+ calls to BLAS/Lapack? If not, why attempt linking to Lapack95/BLAS95?
  • Does your code contain C/C++ functions? If not, why link to CBLAS?
  • Does your code contain C routines that were generated by translation from F77 to C using F2C? If not, why are there invocations of functions/subroutines with the prefix "f2c_"?

We really need to be informed as to what your sources contain. Once that is determined, we could advise you regarding how to proceed, or you could use the MKL Link Line Advisor, https://software.intel.com/en-us/articles/intel-mkl-link-line-advisor .

0 Kudos
TimP
Honored Contributor III
1,052 Views

While gfortran and possibly lapack and blas libraries built for it may include f2c compatibility, those errors appear to indicate you are trying to link libraries which aren't compatible with mkl or Intel windows compilers.

0 Kudos
Reply