VC: Error lnk2019: unresolved external symbol *** referenced in function *** Solution

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.