Beginner's Problems with LNK2019: unresolved external symbol

Beginner's Problems with LNK2019: unresolved external symbol

james.reeder's picture

Hello all, I am not a programmer by trade, but I have been working with Visual Basic 2008 to solve some econometric problems. In donwloading the Parallel Studio XE 2011, with the MKL library, I came across some linear algebra functions that are highly useful. One particular one, sgels, I am trying to use in my code to simplify some steps, but I keep getting the following error: 1>SMM Trial.obj : error LNK2019: unresolved external symbol _sgels referenced in function _main

1>SMM Trial.obj : error LNK2019: unresolved external symbol _sgels referenced in function : fatal error LNK1120: 1 unresolved externals I have tried to add the, what I assume, are correct pathways and libraries to the linker to call in this function, but to no avail. Any help you can provide is greatly appreciated. James

4 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.
mecej4's picture

You have described the problem, but left out much of the detail that is needed to analyze the failure to link.

How is SGELS being called? From Basic or C? Which compiler options were used? What was the linker line?

Much of the missing information is often to be found in the build log in VisualStudio. Simply posting such a log from the failed build may suffice to diagnose the problem.

There are several examples of calling SGELS from C in the ...\ComposerXE-2011\mkl\examples\lapacke\source directory, using the new LapackE interface, which makes calling Lapack routines from C more natural and less error-prone than having to call Fortran routines and attending to the issues related to mixed-language programming.

james.reeder's picture

Hello, Thank you for your response. I am calling sgels as LAPACKE_sgels from the Lapack routiene. I am using Basic not C to call the fuction and I am using the Intel Compiler. The linker line is coming standard from the installation of the Parallel Studio with MKL. Here is the build log requested: Build Log

Build started: Project: SMM Trial, Configuration: Debug|Win32
Command Lines
Creating temporary file "c:\Users\Chet\Documents\Visual Studio 2008\Projects\SMM Trial\SMM Trial\Debug\RSP000004101207652.rsp" with contents
[
/OUT:"C:\Users\Chet\Documents\Visual Studio 2008\Projects\SMM Trial\Debug\SMM Trial.exe" /INCREMENTAL /LIBPATH:"C:\Program Files (x86)\Intel\ComposerXE-2011\mkl\interfaces\lapack95" /LIBPATH:"C:\Program Files (x86)\Intel\ComposerXE-2011\mkl\include" /LIBPATH:"C:\Program Files (x86)\Intel\ComposerXE-2011\mkl\lib\intel64" /LIBPATH:"C:\Program Files (x86)\Intel\ComposerXE-2011\MKL\lib\ia32" /MANIFEST /MANIFESTFILE:"Debug\SMM Trial.exe.intermediate.manifest" /MANIFESTUAC:"level='asInvoker' uiAccess='false'" /DEBUG /PDB:"C:\Users\Chet\Documents\Visual Studio 2008\Projects\SMM Trial\Debug\SMM Trial.pdb" /SUBSYSTEM:CONSOLE /DYNAMICBASE /NXCOMPAT /MACHINE:X86 mkl_solver.lib mkl_intel_c_dll.lib mkl_sequential_dll.lib mkl_core_dll.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib

".\Debug\SMM Trial.obj"

".\Debug\stdafx.obj"

".\Debug\SMM Trial.exe.embed.manifest.res"
]
Creating command line "link.exe @"c:\Users\Chet\Documents\Visual Studio 2008\Projects\SMM Trial\SMM Trial\Debug\RSP000004101207652.rsp" /NOLOGO /ERRORREPORT:PROMPT"
Output Window
Linking...
mkl_intel_c_dll.lib(_memo_mkl_malloc_c.obj) : error LNK2019: unresolved external symbol _mkl_serv_mkl_malloc referenced in function _MKL_malloc
mkl_intel_c_dll.lib(_memo_mkl_free_c.obj) : error LNK2019: unresolved external symbol _mkl_serv_mkl_free referenced in function _MKL_free
mkl_intel_c_dll.lib(_sgels.obj) : error LNK2019: unresolved external symbol _mkl_serv_set_progress referenced in function _sgels
mkl_intel_c_dll.lib(_sgels.obj) : error LNK2019: unresolved external symbol _mkl_serv_setxer referenced in function _sgels
mkl_intel_c_dll.lib(_sgels.obj) : error LNK2019: unresolved external symbol _mkl_lapack_sgels referenced in function _sgels
mkl_intel_c_dll.lib(_MKL_Somatcopy.obj) : error LNK2019: unresolved external symbol _mkl_trans_mkl_somatcopy referenced in function _MKL_Somatcopy
mkl_intel_c_dll.lib(_misc_mkl_progress_iface_u.obj) : error LNK2019: unresolved external symbol _mkl_serv_default_progress referenced in function _MKL_PROGRESS
mkl_intel_c_dll.lib(_misc_mkl_xerbla_iface_u.obj) : error LNK2019: unresolved external symbol _mkl_serv_default_xerbla referenced in function _XERBLA
C:\Users\Chet\Documents\Visual Studio 2008\Projects\SMM Trial\Debug\SMM Trial.exe : fatal error LNK1120: 8 unresolved externals
Results
Build log was saved at "file://c:\Users\Chet\Documents\Visual Studio 2008\Projects\SMM Trial\SMM Trial\Debug\BuildLog.htm"
SMM Trial - 9 error(s), 0 warning(s)

Thank you for your time.
James
mecej4's picture

You have one library directory specified which caused the problems:

/LIBPATH:"C:\Program Files (x86)\Intel\ComposerXE-2011\mkl\lib\intel64"

which will cause an attempt to link 64-bit libraries with 32-bit objects.

The entry

/LIBPATH:"C:\Program Files (x86)\Intel\ComposerXE-2011\mkl\include"

is also incorrect unless, in an unlikely setup, you have libraries installed in an INCLUDE directory.

Leave out the Lapack95 library unless you are making Fortran95-interface calls to Lapack.

Login to leave a comment.