Reputation: 193
I am trying a Create a Linux C++ project using the same header and .cpp
files from a Windows C++ project using Visual Studio. I am using below function to load a DLL dynamically in Windows
HINSTANCE hGetProcIDDLL = LoadLibraryA(sDllPath.c_str());
GetPluginInfoList GetInfoList = (GetPluginInfoList)GetProcAddress(hGetProcIDDLL, "GetPluginInfoList");
I think these functions hail from <windows.h>
When it comes to Linux C++ project I am not getting those functionalities.
For Linux C++, what is the replacement for HINSTANCE
and LoadLibraryA
?
Upvotes: 2
Views: 2078
Reputation: 193
I am posting my answer here. Thanks everyone for the support
typedef CPluginInfoList(*GetPluginInfoList)(void);
#if _WINDLL
HINSTANCE hGetProcIDDLL = LoadLibraryA(sDllPath.c_str());
#else
void* hGetProcIDDLL = dlopen(sDllPath.c_str(), RTLD_LAZY);
#endif
#if _WINDLL
GetPluginInfoList GetInfoList = (GetPluginInfoList)GetProcAddress(hGetProcIDDLL, "GetPluginInfoList");
#else
GetPluginInfoList GetInfoList = (GetPluginInfoList)dlsym(hGetProcIDDLL, "GetPluginInfoList");
#endif
GetInfoList(); //Function Call
Upvotes: 3