So, I link all the native libraries with the .dlls that are used in the WPF application.
I did this with other projects that were compiled into libs, but the latter does not work anyway, although everything seems to be the same. I liked it:
.h:
#ifndef MYHEADER_H_
#define MYHEADER_H_
#ifdef __cplusplus
extern "C" {
#endif
void MySetLoginResultCallback(int(*Callback)(int Ok, const char *UserName));
#ifdef __cplusplus
}
#endif
#endif
.cpp
typedef int(*LoginResultCB_t)(int IsOk, const char *UserName);
LoginResultCB_t gLoginResultCB;
void MySetLoginResultCallback(LoginResultCB_t pCB)
{
gLoginResultCB = pCB;
}
extern "C" __declspec(dllexport) int MyLoginResultCB(int Ok, cons char *UserName)
{
if (gLoginResultCB)
return gLoginResultCB(Ok, UserName);
return -1;
}
MyLoginResultCB is imported into WPF exe and called from there. Upon initialization, MySetLoginResultCallback is called from the C file in native.dll.
In .dll linking I get an unresolved error from MySetLoginResultCallback (which is called in the .c file). If I leave the title exactly the same and rename .cpp → .c and delete extern "C". The .dll utility failed. What am I missing here?
a call from aini.c
MySetLoginResultCallback(XpAfterLoginCB);
Mistake:
1 > aini.obj: LNK2019: _MySetLoginResultCallback, _InitNoAKit