Analysis of "error LNK2019: unresolved external symbols"

Source: Internet
Author: User

Http://www.cnblogs.com/hiloves/p/4678848.html

    1. The essence of this error is that the linker cannot find the function definition in the compiled obj, lib, or DLL file.
    2. The problem I encountered was mixed C and C + +.

You write your own function declaration of the header file also wrote the function definition of the CPP file also joined the project and you are sure that the function body is definitely in this library file, but still appear LNK2019 error. Possible reasons:C and C + + language mixed, because C + + support function overloading so the C + + compiler generated by the library file function name will be unrecognizable, such as the C compiler will generate _readregmark this function name, and C + + compiler generated "void __ Cdecl Readregmark (char *) "([email protected]@[email protected]) such a function name. When your function is written in C, the VS compiler will be compiled according to the C language rules, but the linker does not know that it is silly to use the C + + rules of the function name to find the results can not be found, and you are sure TM is not in this library you a blind. Workaround: Add the header file in the C language

#ifdef __cplusplus extern " C " {#endifvoid readregmark (char *regmark);  // write the function declaration here #ifdef __cplusplus} #endif

Give the linker a hint that this function is C language, do not look for the wrong TM.

Analysis of "error LNK2019: unresolved external symbols"

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.