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
?
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
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.