I am learning plugin system in C++ on the windows by using MinGW g++ compiler. the compiler version is :
C:\SAVVY\src>g++ --version g++ (MinGW.org GCC Build-2) 9.2.0
And I downloaded the source code from here https://cplusplus.com/articles/48TbqMoL/
then I am trying to figure out the error: Exception caught: Invalid Plugin DLL: both 'getObj' and 'getName' must be defined.
probably the error line are in main.cpp 59, 60
ObjProc objFunc = (ObjProc) GetProcAddress(mod, "_Z6getObjv");
NameProc nameFunc = (NameProc) GetProcAddress(mod, "_Z7getNamev");
I have looked into the word "name mangling", but I can not find the solution. Would somebody, please direct me how to the solution.
That article might be outdated, it's more than 9 years old. The name mangling is not stable and might be change from one to another compiler version. Besides such issue has been reported by a reader 9 years ago and noticed in that article: loading dll issue. Finally that article has been updated with the solution. Go to the chapter Update - Using the plugin system across different compilers and see the solution with using
extern "C".