I'm not sure what's going wrong. I'll describe the problem, followed by my understanding of what's going on. It's a simple code:
#include <iostream>
#include <stdio.h>
#include "stdafx.h"
#include <iViewNG-Core.h>
int main(int argc, char ** args) {
iViewVersion version;
iViewRC rc = iView_GetLibraryVersion(&version);
if (RC_NO_ERROR != rc)
printf("ERROR returned by iView_GetLibraryVersion(): %d\n", rc);
printf("The version of the libiViewNG is: %u.%u.%u.%u\n", version.major, version.minor, version.patch, version.build);
return 0;
}
The error description:
Error LNK2019 unresolved external symbol
__imp__iView_GetLibraryVersion@4 referenced in function _main SMI_TrialTests c:\Users\Rakshit\documents\visual studio 2015\Projects\SMI_TrialTests\SMI_TrialTests\SMI_TrialTests.obj
I confirmed that the code is indeed reading iViewNG-Core.h because the auto-fill lets me use functions declared in the file. I did this by adding the lib and include directory correctly in the appropriate VC++ directories. Since this a linker issue, where am I going wrong?
I am new to C++ and I know there are tons of duplicated LNK2019 questions but none of them seemed to solve my problem.
Linker output:
/OUT:"c:\users\rakshit\documents\visual studio
2015\Projects\SMI_TrialTests\Debug\SMI_TrialTests.exe" /MANIFEST
/NXCOMPAT /PDB:"c:\users\rakshit\documents\visual studio
2015\Projects\SMI_TrialTests\Debug\SMI_TrialTests.pdb" /DYNAMICBASE
"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 /MACHINE:X86 /INCREMENTAL
/PGD:"c:\users\rakshit\documents\visual studio
2015\Projects\SMI_TrialTests\Debug\SMI_TrialTests.pgd"
/SUBSYSTEM:CONSOLE /MANIFESTUAC:"level='asInvoker' uiAccess='false'"
/ManifestFile:"Debug\SMI_TrialTests.exe.intermediate.manifest"
/ERRORREPORT:PROMPT /NOLOGO /VERBOSE /LIBPATH:"C:\iView NG
SDK\lib\lib-Windows7-32" /TLBID:1
Best Answer
Examining the symbol
__imp__iView_GetLibraryVersion@4
, it can be broken into two chunkcs:__imp_
: This means__declspec(dllimport)
._iView_GetLibraryVersion@4
: This is the actual symbol, mangled as a C (orextern "C"
)__stdcall
symbol, where the parameters total 4 bytes in size.Considering this, and going by your code, the function causing the issue is likely:
I would suggest checking that the LIB file for the DLL containing this function is being passed to either
cl
orlink
(in the former case,cl
will pass it tolink
for you).