I am getting linking errors
error LNK2028: unresolved token (0A000018) "extern "C" void __clrcall MyCFunction(struct ud *)" (?MyCFunction@@$$J0YMXPAUud@@@Z) referenced in function "public: __clrcall MyCPPProj::MyClass::MyClass
error LNK2019: unresolved external symbol "extern "C" void __clrcall MyCFunction(struct ud *)" (?MyCFunction@@$$J0YMXPAUud@@@Z) referenced in function "public: __clrcall MyCPPProj::MyClass::MyClass
When I try to call functions in my C static library from a C++ class.
Here is how my library's header begins:
#ifdef __cplusplus
extern "C" {
#endif
#include <stdio.h>
#include "types.h"
extern void MyCFunction(struct myCStruct*);
Here is a snippet from the header's implementation:
extern void
MyCFunction(struct myCStruct* cStrInst)
{
//Do stuff
}
and this is how I am calling it:
#include "MyCLib.h"
MyClass::MyClass() {
myCStruct myCObj;
MyCFunction(&myCObj);
//More to follow...
}
Any one know where I am going wrong? All the advice I can find seems to have already been implemented, i.e. declaring whole header with extern "C" { wrapper (http://www.parashift.com/c++-faq-lite/mixing-c-and-cpp.html).
EDIT I've tried making the C library more C++ compliant and included it as C++ and C with the same result: LNK2028 and LNK2019 linker errors. I made it a static library because projects need to have a type and I needed to see it compile in isolation before adding it to my solution.