I have a project that was originally written in C. It's pretty large so I don't want to re-write it by hand if I can avoid it. The end goal is to embed it in a C# application. I've made and used CLR libraries before, but I'm having trouble with the below.
// CommandParse.h, used in a Win32 DLL
extern "C" {
typedef struct _PARAMS {
PCHAR OutputDir;
//... other members
} PARAMS, *PPARAMS;
// defines in CommandParse.c
__declspec(dllexport) VOID CmdParseParameters(PPARAMS, int, char ** const);
}
I'm using VS2013 for these projects. And the above example is the stereotypical design pattern used in every other component.
// CommandParseWrapper.h, CLR library
namespace WrappedCode {
public ref class CommandParams {
PPARAMS params;
public:
CommandParams() {
params = new PARAMS;
}
void parse(int argc, char ** const argv) {
CmdParseParameters(params, argc, argv);
}
}
}
What I've done in the CLR project is added the Win32DLL project as a reference and added the source code to the "Additional Includes" setting in VS2013. However I've presented with the following errors.
error LNK2019: unresolved external symbol "extern "C" void __cdecl CmdParseParameters(struct _PARAMS *, int, char** const)"...
error LNK2028: unresolved token (0A00002E) "extern "C" void __cdecl CmdParseParameters(struct _PARAMS *, int, char** const)"...
Causing the compilation to fail. Any suggestions?
Note: I'm not against editing the original code.