MKL linking error of the c++ minimal sample

Hello,

I am trying to build the c++ minimal example provided here with the MSVC compiler. I can configure it successfully with cmake. But when linking, it states it cannot find the mkl_intel_ilp64.lib. I have the intel oneAPI installed on my machine and I am afraid this causes the error since cmake finds it. What should I do to correct this behaviour?

Error : LINK : fatal error LNK1104: impossible d’ouvrir le fichier ‘mkl_intel_ilp64.lib’

  • Windows 10
  • Latest Libtorch+cpu (1.12.1)
  • intel oneAPI 2022.1.0.20220316

The CMakeOutputlog.txt:

The system is: Windows - 10.0.19044 - AMD64
Compiling the C compiler identification source file "CMakeCCompilerId.c" succeeded.
Compiler:  
Build flags: 
Id flags:  

The output was:
0
MSBuild version 17.3.1+2badb37d1 for .NET Framework
La génération a démarré 26.09.2022 14:10:56.
Projet "C:\Users\ANONYME\Documents\code\cpp\essai_pytorch\build\CMakeFiles\3.24.0-rc5\CompilerIdC\CompilerIdC.vcxproj" sur le noud 1 (cibles par défaut).
PrepareForBuild:
  Création du répertoire "Debug\".
  Création du répertoire "Debug\CompilerIdC.tlog\".
InitializeBuildStatus:
  Création de "Debug\CompilerIdC.tlog\unsuccessfulbuild", car "AlwaysCreate" a été spécifié.
ClCompile:
  C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.33.31629\bin\HostX64\x64\CL.exe /c /nologo /W0 /WX- /diagnostics:column /Od /D _MBCS /Gm- /EHsc /RTC1 /MDd /GS /Zc:wchar_t /Zc:forScope /Zc:inline /Fo"Debug\\" /Fd"Debug\vc143.pdb" /external:W0 /Gd /TC /FC /errorReport:queue CMakeCCompilerId.c
  CMakeCCompilerId.c
Link:
  C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.33.31629\bin\HostX64\x64\link.exe /ERRORREPORT:QUEUE /OUT:".\CompilerIdC.exe" /INCREMENTAL:NO /NOLOGO kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /MANIFEST /MANIFESTUAC:"level='asInvoker' uiAccess='false'" /manifest:embed /PDB:".\CompilerIdC.pdb" /SUBSYSTEM:CONSOLE /TLBID:1 /DYNAMICBASE /NXCOMPAT /IMPLIB:".\CompilerIdC.lib" /MACHINE:X64 Debug\CMakeCCompilerId.obj
  CompilerIdC.vcxproj -> C:\Users\ANONYME\Documents\code\cpp\essai_pytorch\build\CMakeFiles\3.24.0-rc5\CompilerIdC\CompilerIdC.exe
PostBuildEvent:
  for %%i in (cl.exe) do @echo CMAKE_C_COMPILER=%%~$PATH:i
  :VCEnd
  CMAKE_C_COMPILER=C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.33.31629\bin\Hostx64\x64\cl.exe
FinalizeBuildStatus:
  Suppression du fichier "Debug\CompilerIdC.tlog\unsuccessfulbuild".
  Mise à jour de l'horodatage "Debug\CompilerIdC.tlog\CompilerIdC.lastbuildstate".
Génération du projet "C:\Users\ANONYME\Documents\code\cpp\essai_pytorch\build\CMakeFiles\3.24.0-rc5\CompilerIdC\CompilerIdC.vcxproj" terminée (cibles par défaut).

La génération a réussi.
    0 Avertissement(s)
    0 Erreur(s)

Temps écoulé 00:00:01.60


Compilation of the C compiler identification source "CMakeCCompilerId.c" produced "CompilerIdC.exe"

Compilation of the C compiler identification source "CMakeCCompilerId.c" produced "CompilerIdC.vcxproj"

The C compiler identification is MSVC, found in "C:/Users/ANONYME/Documents/code/cpp/essai_pytorch/build/CMakeFiles/3.24.0-rc5/CompilerIdC/CompilerIdC.exe"

Compiling the CXX compiler identification source file "CMakeCXXCompilerId.cpp" succeeded.
Compiler:  
Build flags: 
Id flags:  

The output was:
0
MSBuild version 17.3.1+2badb37d1 for .NET Framework
La génération a démarré 26.09.2022 14:10:58.
Projet "C:\Users\ANONYME\Documents\code\cpp\essai_pytorch\build\CMakeFiles\3.24.0-rc5\CompilerIdCXX\CompilerIdCXX.vcxproj" sur le noud 1 (cibles par défaut).
PrepareForBuild:
  Création du répertoire "Debug\".
  Création du répertoire "Debug\CompilerIdCXX.tlog\".
InitializeBuildStatus:
  Création de "Debug\CompilerIdCXX.tlog\unsuccessfulbuild", car "AlwaysCreate" a été spécifié.
ClCompile:
  C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.33.31629\bin\HostX64\x64\CL.exe /c /nologo /W0 /WX- /diagnostics:column /Od /D _MBCS /Gm- /EHsc /RTC1 /MDd /GS /Zc:wchar_t /Zc:forScope /Zc:inline /Fo"Debug\\" /Fd"Debug\vc143.pdb" /external:W0 /Gd /TP /FC /errorReport:queue CMakeCXXCompilerId.cpp
  CMakeCXXCompilerId.cpp
Link:
  C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.33.31629\bin\HostX64\x64\link.exe /ERRORREPORT:QUEUE /OUT:".\CompilerIdCXX.exe" /INCREMENTAL:NO /NOLOGO kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /MANIFEST /MANIFESTUAC:"level='asInvoker' uiAccess='false'" /manifest:embed /PDB:".\CompilerIdCXX.pdb" /SUBSYSTEM:CONSOLE /TLBID:1 /DYNAMICBASE /NXCOMPAT /IMPLIB:".\CompilerIdCXX.lib" /MACHINE:X64 Debug\CMakeCXXCompilerId.obj
  CompilerIdCXX.vcxproj -> C:\Users\ANONYME\Documents\code\cpp\essai_pytorch\build\CMakeFiles\3.24.0-rc5\CompilerIdCXX\CompilerIdCXX.exe
PostBuildEvent:
  for %%i in (cl.exe) do @echo CMAKE_CXX_COMPILER=%%~$PATH:i
  :VCEnd
  CMAKE_CXX_COMPILER=C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.33.31629\bin\Hostx64\x64\cl.exe
FinalizeBuildStatus:
  Suppression du fichier "Debug\CompilerIdCXX.tlog\unsuccessfulbuild".
  Mise à jour de l'horodatage "Debug\CompilerIdCXX.tlog\CompilerIdCXX.lastbuildstate".
Génération du projet "C:\Users\ANONYME\Documents\code\cpp\essai_pytorch\build\CMakeFiles\3.24.0-rc5\CompilerIdCXX\CompilerIdCXX.vcxproj" terminée (cibles par défaut).

La génération a réussi.
    0 Avertissement(s)
    0 Erreur(s)

Temps écoulé 00:00:01.30


Compilation of the CXX compiler identification source "CMakeCXXCompilerId.cpp" produced "CompilerIdCXX.exe"

Compilation of the CXX compiler identification source "CMakeCXXCompilerId.cpp" produced "CompilerIdCXX.vcxproj"

The CXX compiler identification is MSVC, found in "C:/Users/ANONYME/Documents/code/cpp/essai_pytorch/build/CMakeFiles/3.24.0-rc5/CompilerIdCXX/CompilerIdCXX.exe"

Detecting C compiler ABI info compiled with the following output:
Change Dir: C:/Users/ANONYME/Documents/code/cpp/essai_pytorch/build/CMakeFiles/CMakeTmp

Run Build Command(s):C:/Program Files/Microsoft Visual Studio/2022/Community/MSBuild/Current/Bin/amd64/MSBuild.exe cmTC_be492.vcxproj /p:Configuration=Debug /p:Platform=x64 /p:VisualStudioVersion=17.0 /v:m && MSBuild version 17.3.1+2badb37d1 for .NET Framework

  Compilateur d'optimisation Microsoft (R) C/C++ version 19.33.31629 pour x64

  CMakeCCompilerABI.c

  Copyright (C) Microsoft Corporation. Tous droits réservés.

  cl /c /Zi /W3 /WX- /diagnostics:column /Od /Ob0 /D _MBCS /D WIN32 /D _WINDOWS /D "CMAKE_INTDIR=\"Debug\"" /Gm- /RTC1 /MDd /GS /Zc:wchar_t /Zc:forScope /Zc:inline /Fo"cmTC_be492.dir\Debug\\" /Fd"cmTC_be492.dir\Debug\vc143.pdb" /external:W3 /Gd /TC /errorReport:queue "C:\Installations\CMake\share\cmake-3.24\Modules\CMakeCCompilerABI.c"

  cmTC_be492.vcxproj -> C:\Users\ANONYME\Documents\code\cpp\essai_pytorch\build\CMakeFiles\CMakeTmp\Debug\cmTC_be492.exe




Detecting CXX compiler ABI info compiled with the following output:
Change Dir: C:/Users/ANONYME/Documents/code/cpp/essai_pytorch/build/CMakeFiles/CMakeTmp

Run Build Command(s):C:/Program Files/Microsoft Visual Studio/2022/Community/MSBuild/Current/Bin/amd64/MSBuild.exe cmTC_90d57.vcxproj /p:Configuration=Debug /p:Platform=x64 /p:VisualStudioVersion=17.0 /v:m && MSBuild version 17.3.1+2badb37d1 for .NET Framework

  Compilateur d'optimisation Microsoft (R) C/C++ version 19.33.31629 pour x64

  CMakeCXXCompilerABI.cpp

  Copyright (C) Microsoft Corporation. Tous droits réservés.

  cl /c /Zi /W3 /WX- /diagnostics:column /Od /Ob0 /D _MBCS /D WIN32 /D _WINDOWS /D "CMAKE_INTDIR=\"Debug\"" /Gm- /EHsc /RTC1 /MDd /GS /Zc:wchar_t /Zc:forScope /Zc:inline /GR /Fo"cmTC_90d57.dir\Debug\\" /Fd"cmTC_90d57.dir\Debug\vc143.pdb" /external:W3 /Gd /TP /errorReport:queue "C:\Installations\CMake\share\cmake-3.24\Modules\CMakeCXXCompilerABI.cpp"

  cmTC_90d57.vcxproj -> C:\Users\ANONYME\Documents\code\cpp\essai_pytorch\build\CMakeFiles\CMakeTmp\Debug\cmTC_90d57.exe

I thank you in advance for your help.

Hi Chenoille,
I have the same problem. Did you find a solution to it?
Thanks
Alok

Hello,
The problem was that my cuda compatibility (3.5) was too low for the newest versions of Pytorch. I had to go back to Pytorch 1.6.
If your cuda compatibility is adequate, you can then use this website to check if you have problems with loading dlls on Windows.
I hope it helps.

Have a nice day,
Maxime

1 Like