DllMain is never called in mingw g++ compiled dll

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(…)

 

Did you like this?
Tip admin with Cryptocurrency

Donate Bitcoin to admin

Scan to Donate Bitcoin to admin
Scan the QR code or copy the address below into your wallet to send some bitcoin:

Donate Bitcoin Cash to admin

Scan to Donate Bitcoin Cash to admin
Scan the QR code or copy the address below into your wallet to send bitcoin:

Donate Ethereum to admin

Scan to Donate Ethereum to admin
Scan the QR code or copy the address below into your wallet to send some Ether:

Donate Litecoin to admin

Scan to Donate Litecoin to admin
Scan the QR code or copy the address below into your wallet to send some Litecoin:

Donate Monero to admin

Scan to Donate Monero to admin
Scan the QR code or copy the address below into your wallet to send some Monero:

Donate ZCash to admin

Scan to Donate ZCash to admin
Scan the QR code or copy the address below into your wallet to send some ZCash:

Comments are closed, but trackbacks and pingbacks are open.