I have the C++ project in which i added some pure C gnu library. I was tasked to change some of the functions, that is used there for the ones, that are needed to be loaded dynamically from dll, so what i did is, i declared the prototype, and made an extern variable:
file prototypes.h:
typedef char *( __cdecl * _ReParseHtml ) ( DOM * data )
file func_defs.h
extern _ReParseHtml DllReParseHtml;
then in my, main file program.cpp i declared:
_ReParseHtml DllReParseHtml;
int APIENTRY wWinMain(_In_ HINSTANCE hInstance,
_In_opt_ HINSTANCE hPrevInstance,
_In_ LPWSTR lpCmdLine,
_In_ int nCmdShow)
{
HINSTANCE hDLL = LoadLibrary("somelib.dll");
if(hDll != 0){
DllReParseHtml = (_ReParseHtml)GetProcAddress(hDLL,
"ReParseHtml");
//etc
}
}
So now i want to use this in the pure .c
file which i added:
parser.c:
#include "func_defs.h" // here is the extern _ReParseHtml DllReParseHtml;
int create_source(char * buf)
{
char * modified = DllReParseHtml(buf);
// etc..
}
But i get the error LNK2001 unresolved external symbol DllReParseHtml
.
The function in purce C source int create_source(char * buf)
from which this functions suppose to be called is not in the extern "C" { }
block, or anything like that.