Intel® oneAPI Math Kernel Library
Ask questions and share information with other developers who use Intel® Math Kernel Library.
Announcements
This community is designed for sharing of public information. Please do not share Intel or third-party confidential information here.
6559 Discussions

Building a C VML example in Visual Studio 2019

khalidEng
Beginner
374 Views

Hi All,

I am trying to build one of the examples provided with oneMKL in \Program Files (x86)\Intel\oneAPI\mkl\2021.3.0\examples\examples_core_c\c\vml\source.  I am using vdasin.c as the example.  I created a VS project, added the source file, header files, got it to compile, but the linker is complaining Error LNK2019 unresolved external symbol _vmdAsin referenced in function _main myVecTest1 vdasin.obj 1

 

So I am trying to do a very simple example in VS using oneKML but having a hard time building an executable using a simple VML oneKML function.  Searched the web for a complete VS project but  unfortunately no luck.

0 Kudos
9 Replies
mecej4
Black Belt
352 Views

Whether you use Visual Studio or build at the command line, by default MKL is not used, which is quite reasonable since you can have a working compiler package without having MKL installed at all.

You need to edit the project settings and specify that it should use MKL.

khalidEng
Beginner
277 Views

I did edit the project setting and specified the mkl_rtl.lib library, which contains the vdAsin function but for some strange reason the Visual Studio linker is not able to find that function, or any of the other functions in the vdasin.c example file.

Is there something I am missing that I need to set the linker options so that it will work with mkl_rt.lib?   I have been trying linker advisor with different libraries nothing seems to work.  It's like Visual Studio 2019 doesn't see the library or does see it but not finding the function due to some mismatch.

 

Severity Code Description Project File Line Suppression State
Error LNK2019 unresolved external symbol _vdAsin referenced in function _main myVecTest1 C:\Users\khalmufti\source\repos\myVecTest1\myVecTest1\vdasin.obj 1
Error LNK2019 unresolved external symbol _vmdAsin referenced in function _main myVecTest1 C:\Users\khalmufti\source\repos\myVecTest1\myVecTest1\vdasin.obj 1
Error LNK2019 unresolved external symbol _vdAsinI referenced in function _main myVecTest1 C:\Users\khalmufti\source\repos\myVecTest1\myVecTest1\vdasin.obj 1
Error LNK2019 unresolved external symbol _vmdAsinI referenced in function _main myVecTest1 C:\Users\khalmufti\source\repos\myVecTest1\myVecTest1\vdasin.obj 1
Error LNK2019 unresolved external symbol _vmlSetMode referenced in function _main myVecTest1 C:\Users\khalmufti\source\repos\myVecTest1\myVecTest1\vdasin.obj 1
Error LNK1120 5 unresolved externals myVecTest1 C:\Users\khalmufti\source\repos\myVecTest1\Debug\myVecTest1.exe 1

khalidEng
Beginner
344 Views

I did edit the project setting and specified the mkl_rtl.lib library, which contains the vdAsin function but for some strange reason the Visual Studio linker is not able to find that function, or any of the other functions in the vdasin.c example file.

Is there something I am missing that I need to set the linker options so that it will work with mkl_rt.lib?   I have been trying linker advisor with different libraries nothing seems to work.  It's like Visual Studio 2019 doesn't see the library or does see it but not finding the function due to some mismatch.

 

Severity Code Description Project File Line Suppression State
Error LNK2019 unresolved external symbol _vdAsin referenced in function _main myVecTest1 C:\Users\khalmufti\source\repos\myVecTest1\myVecTest1\vdasin.obj 1
Error LNK2019 unresolved external symbol _vmdAsin referenced in function _main myVecTest1 C:\Users\khalmufti\source\repos\myVecTest1\myVecTest1\vdasin.obj 1
Error LNK2019 unresolved external symbol _vdAsinI referenced in function _main myVecTest1 C:\Users\khalmufti\source\repos\myVecTest1\myVecTest1\vdasin.obj 1
Error LNK2019 unresolved external symbol _vmdAsinI referenced in function _main myVecTest1 C:\Users\khalmufti\source\repos\myVecTest1\myVecTest1\vdasin.obj 1
Error LNK2019 unresolved external symbol _vmlSetMode referenced in function _main myVecTest1 C:\Users\khalmufti\source\repos\myVecTest1\myVecTest1\vdasin.obj 1
Error LNK1120 5 unresolved externals myVecTest1 C:\Users\khalmufti\source\repos\myVecTest1\Debug\myVecTest1.exe 1

mecej4
Black Belt
307 Views

Whether you use the MS C/C++ compiler or the Intel C/C++ compiler, for this simple problem mkl_rt.lib is sufficient (note the spelling, it is not mkl_rtl.lib). Adjust the path to the library in the following command to match your installation:

cl /O2 /MD vdasin.c c:\LANG\OneAPI\mkl\latest\lib\intel64\mkl_rt.lib

 Provided the environment (variables INCLUDE, LIB, PATH) has been correctly set up, you should be able to do the equivalent from within Visual Studio, as well. For details, please see this article.

mecej4
Black Belt
338 Views

I just now built and ran the vdasin.c example, with no problems whatsoever, using the command

icl /O2 /MD /Qmkl vdasin.c

Merely listing error messages is rarely enough to enable troubleshooting the problem. We have all seen "unresolved external symbol..." messages before, and they exist for very good reasons. On the other hand, there are often multiple reasons for their being displayed, and seeing just the message is not enough to ascertain which particular reason is relevant.

Please reply, attaching the buildlog.html file that is generated by Visual Studio.

khalidEng
Beginner
326 Views

Okay.  So the command line you used is for the intel compiler, not Visual Studio C/C++, which probably explains why it worked no problem for you, but for me with VS Compile/linker something is not setup correctly.

I am copy and pasting the last part of the build output window, the full file is attached.  I turned on verbosity level to detailed, but if needed can send with diagnostic level.

1>Target Link:
1> Using "Link" task from assembly "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Microsoft\VC\v160\Microsoft.Build.CppTasks.Common.dll".
1> Task "Link"
1> Write Tracking Logs:
1> Debug\myVecTest1.tlog\link.write.1.tlog
1> Debug\myVecTest1.tlog\link-cvtres.write.1.tlog
1> Debug\myVecTest1.tlog\link-rc.write.1.tlog
1> Read Tracking Logs:
1> Debug\myVecTest1.tlog\link.read.1.tlog
1> Debug\myVecTest1.tlog\link-cvtres.read.1.tlog
1> Debug\myVecTest1.tlog\link-rc.read.1.tlog
1> No output for C:\USERS\KHALMUFTI\SOURCE\REPOS\MYVECTEST1\MYVECTEST1\DEBUG\VDASIN.OBJ was found in the tracking log; source compilation required.
1> No dependencies for output C:\USERS\KHALMUFTI\SOURCE\REPOS\MYVECTEST1\MYVECTEST1\DEBUG\VDASIN.OBJ were found in the tracking log; source compilation required.
1> Environment Variables passed to tool:
1> VS_UNICODE_OUTPUT=1156
1> C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30037\bin\HostX86\x86\link.exe /ERRORREPORT:PROMPT /OUT:"C:\Users\khalmufti\source\repos\myVecTest1\Debug\myVecTest1.exe" /INCREMENTAL /ILK:"Debug\myVecTest1.ilk" /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 /DEBUG /PDB:"C:\Users\khalmufti\source\repos\myVecTest1\Debug\myVecTest1.pdb" /SUBSYSTEM:CONSOLE /TLBID:1 /DYNAMICBASE /NXCOMPAT /IMPLIB:"C:\Users\khalmufti\source\repos\myVecTest1\Debug\myVecTest1.lib" /MACHINE:X86 Debug\vdasin.obj
1> Tracking command:
1> C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Current\Bin\Tracker.exe /a /d "C:\Program Files (x86)\MSBuild\15.0\FileTracker\FileTracker32.dll" /i C:\Users\khalmufti\source\repos\myVecTest1\myVecTest1\Debug\myVecTest1.tlog /r C:\USERS\KHALMUFTI\SOURCE\REPOS\MYVECTEST1\MYVECTEST1\DEBUG\VDASIN.OBJ /b MSBuildConsole_CancelEventd9f64f3c0af54f3894c6852904ed91b7 /c "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30037\bin\HostX86\x86\link.exe" /ERRORREPORT:PROMPT /OUT:"C:\Users\khalmufti\source\repos\myVecTest1\Debug\myVecTest1.exe" /INCREMENTAL /ILK:"Debug\myVecTest1.ilk" /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 /DEBUG /PDB:"C:\Users\khalmufti\source\repos\myVecTest1\Debug\myVecTest1.pdb" /SUBSYSTEM:CONSOLE /TLBID:1 /DYNAMICBASE /NXCOMPAT /IMPLIB:"C:\Users\khalmufti\source\repos\myVecTest1\Debug\myVecTest1.lib" /MACHINE:X86 Debug\vdasin.obj
1> vdasin.obj : error LNK2019: unresolved external symbol _vdAsin referenced in function _main
1> vdasin.obj : error LNK2019: unresolved external symbol _vmdAsin referenced in function _main
1> vdasin.obj : error LNK2019: unresolved external symbol _vdAsinI referenced in function _main
1> vdasin.obj : error LNK2019: unresolved external symbol _vmdAsinI referenced in function _main
1> vdasin.obj : error LNK2019: unresolved external symbol _vmlSetMode referenced in function _main
1> C:\Users\khalmufti\source\repos\myVecTest1\Debug\myVecTest1.exe : fatal error LNK1120: 5 unresolved externals
1> The command exited with code 1120.
1> Done executing task "Link" -- FAILED.
1>Done building target "Link" in project "myVecTest1.vcxproj" -- FAILED.
1>
1>Done building project "myVecTest1.vcxproj" -- FAILED.
1>
1>Build FAILED.
1>
1>vdasin.obj : error LNK2019: unresolved external symbol _vdAsin referenced in function _main
1>vdasin.obj : error LNK2019: unresolved external symbol _vmdAsin referenced in function _main
1>vdasin.obj : error LNK2019: unresolved external symbol _vdAsinI referenced in function _main
1>vdasin.obj : error LNK2019: unresolved external symbol _vmdAsinI referenced in function _main
1>vdasin.obj : error LNK2019: unresolved external symbol _vmlSetMode referenced in function _main
1>C:\Users\khalmufti\source\repos\myVecTest1\Debug\myVecTest1.exe : fatal error LNK1120: 5 unresolved externals
1> 0 Warning(s)
1> 6 Error(s)
1>
1>Time Elapsed 00:00:00.23
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

khalidEng
Beginner
324 Views

Hi Black Belt,

Now that I am looking at the output log, as you suggested, I see couple of issues, for one, when I search for mkl_rt.lib, which has the definition of these unresolved symbols, I don't find it!  Somehow it seems the linker never found or included it! 

khalidEng
Beginner
316 Views

Problem solved!  The issue was that the Configuration Properties: Platform was set to x86 instead of x64, which is how I set everything else, including the mkl_rt.lib from the \intel64 directory.

Now build is successful.

 

ArpitaP_Intel
Moderator
299 Views

Hi Khalid,


Glad to know that your issue is resolved. If you need any additional information, please submit a new question as this thread will no longer be monitored.


Thanks!


Reply