We know that dll has a entry function:
BOOL WINAPI DllMain(…)
This function is called whenever the dll is loaded such as by LoadLibrary() function. We may do some initialization work in this function. This works fine when I compiled the dll using gcc. But when I build this dll using g++, this entry function is never called. I mean when calling LoadLibrary() to load this dll, it never goes into DllMain. Is there some difference between g++ and gcc compiled dlls? The problem is actually caused by the name mangling of g++(see http://comments.gmane.org/gmane.comp.gnu.mingw.user/7470). To let the system find DllMain successfully, you should define the function as:
extern “C” BOOL WINAPI DllMain(…)
Comments are closed, but trackbacks and pingbacks are open.