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.