Hi, I am loading a DLL from an application and I want the DLL to be able to use a function implemented in the application. The definition of the function is put in a header and is included in the DLL. Can anyone tell me what I am doing wrong here or whether this can't be done? Thanks for any help.
App:
include <API.h>
extern "C" int Mult(int x, int y)
{
return x*y;
}
int main(int argc, char **argv)
{
if(argc <= 1)
return -1;
void * pHandle = dlopen(argv[1], RTLD_NOW);
if(pHandle == NULL)
{
cout << "Can't find DLL : " << argv[1] << endl;
cout << dlerror() << endl;
return -2;
}
else
cout << "DLL Loaded" << endl;
The API.h file:
#ifndef __APP_API__
#define __APP_API__
extern "C" int Mult(int x, int y);
#endif
And the DLL:
#include <API.h>
int Imp1::GetFunctionID()
{
return Mult(42, 42);
}
When run, this gives me the error:
Can't find DLL : ./ll.d.so ./ll.d.so: undefined symbol: Mult
Please help. Thanks