Error lnk2019: unresolved external symbol

Source: Internet
Author: User

The recently written program has two projects in a solution. a c ++ project calls the C Project, and the link always appears during compilation.
Error, error lnk2019: unresolved external symbol. After checking for a long time, I found the following solution, which is very good.

Http://blogs.msdn.com/vsdteam/archive/2005/11/20/495123.aspx
Error lnk2019: unresolved external symbol int _ cdecl cemountdbvolex, void * _ cdecl ceopendatabaseinsession

You
Have created a C ++ device project and using the EDB methods from
"Coredll. lib". You have included the "windbase_edb.h" file in your
Projects source files. When you compile and link this you are getting
Following linker errors

Error lnk2019: unresolved external
Symbol "int _ cdecl cemountdbvolex (struct _ ceguid *, wchar_t *, struct
_ Cevolumeoptions *, unsigned long )"(? Cemountdbvolex @ yahpau_ceguid @ pa_wpau_cevolumeoptions @ k @ Z) referenced in function "int _ cdecl mountdbvol (void )"(? Mountdbvol @ yahxz)

Error
Lnk2019: unresolved external symbol "Void * _ cdecl
Ceopendatabaseinsession (void *, struct _ ceguid *, unsigned long *, wchar_t
*, Struct _ sortorderspecex *, unsigned long, struct _ cenotifyrequest *)"(? Ceopendatabaseinsession @ yapaxpaxpau_ceguid @ pakpa_wpau_sortorderspecex @ kpau_cenotifyrequest @ Z)

And you are wondering why this is happening?

The
Problem with your project is that you are using a "C" style exported
Library in your c ++ projects. When the compiler generates mangled names
For C ++ functions, they are different from unmangled names generated
The C compiler and hence the C ++ compiler will not be able to link
The methods imported from coredll. Lib.

The solution to this
Problem is-while including the header windbase_edb.h, you can
Explicitly tell the compiler that all functions included from this
Header are "C" style functions by changing your injection sion as below.

Extern "C"
{
# Include
}

With
This the C ++ compiler when provided des the declarations from
Windbase_edb.h file, it does not do any name mangling for the functions
Declared in this file, and thus you shoshould be able to link to EDB
Without any problems now.

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.