When a function is declared in the header file but is not defined in the corresponding source file, an unresolved external symbol error occurs. In addition, when a function calls a function in an external library file but does not include the dependent library file in the properties of the current project, this error also occurs.
In summary, when a solution cannot find the definition of the involved function in linking, the "unresolved external symbol" error will occur.
For example, the following is a link error caused by the absence of rapi. Lib inclusion when calling the functions in rapi library file rapi. Lib.
1> linking...
Wmfilesync. OBJ: Error lnk2019: unresolved external symbol [email protected] referenced in function "public: Virtual long _ stdcall cwmfilesync: isfileexists (wchar_t *) "([email protected] @ [email protected])
[Solution]
1. Project-> ** properties...-> Configuration properties-> linker-> input-> additional dependencies-> rapi. Lib
In addition, you also need to add the corresponding directory of the rapi library before: tools-> options-> projects and solutions-> VC ++ directories-> show directories for-> Add C: \ Program Files \ matrox imaging \ rapi \ include and tools-> options-> projects and solutions-> VC ++ directories-> show directories for-> Add C in library files: \ Program Files \ matrox imaging \ rapi \ Lib. The purpose of adding a directory is to make Vc do not always use an absolute address when calling the corresponding library file. VC can search by file name in the contained directory. In this way, the previous rapi. Lib does not need to use an absolute address.
[Disadvantage] Poor portability. If you copy the source and header files in the original project and re-create the project (for example, a program found on an e-book or on the Internet ), you still need to add directories and required library files in the project.
2. Add # pragma commet (Lib, "rapi. lib") before the program to achieve the same effect.
[This blog post is reposted online]
VC: Error lnk2019: unresolved external symbol *** referenced in function *** Solution