Problem with GetModuleHandleEx in MinGW

Discussion area about developing or extending OGRE, adding plugins for it or building applications on it. No newbie questions please, use the Help forum for that.
Post Reply
User avatar
Eugene
OGRE Team Member
OGRE Team Member
Posts: 185
Joined: Mon Mar 24, 2008 4:54 pm
Location: Odessa, Ukraine
x 41

Problem with GetModuleHandleEx in MinGW

Post by Eugene »

I saw this patch https://bitbucket.org/sinbad/ogre/commi ... 3275550c68 and was surprised.

The first problem - patch always looks for handle of OgreMain.dll or OgreMain_d.dll, even inside RenderSystem_OpenGL.dll. It also ignores OGRE_STATIC_LIB setting, in which case GetModuleHandle(NULL) should be called. So at least, it should be fixed.

But actually, there are much better news - GetModuleHandleEx is supported under MinGW, and this is natural, as this API available since WinXP.
I checked w32api-4.03, w32api-3.17 and w32api-3.11, GetModuleHandleEx is there, under #if (_WIN32_WINNT >= _WIN32_WINNT_WINXP) protection.
So, probably it would be better to revert this patch and just #define _WIN32_WINNT to _WIN32_WINNT_WINXP somewhere in OgrePrerequisites if it is not yet defined, as it seem to be with MinGW.

TheSHEEEP
OGRE Retired Team Member
OGRE Retired Team Member
Posts: 972
Joined: Mon Jun 02, 2008 6:52 pm
Location: Berlin
x 63

Re: Problem with GetModuleHandleEx in MinGW

Post by TheSHEEEP »

I am not convinced that GetModuleHandleEx is present in all MinGW versions, which is why I did the patch. It might be, but I'd rather not take the risk.
But the bigger problem... from experience in other projects I can only say that fumbling around with _WIN32_WINNT can lead to all kinds of nastiness, especially when other libraries come into the mix. I don't know how often I had to change things because some library I had no influence over defined that to some weird value (I mean really weird out of nowhere values, not just the WINXP you proposed). Heck, some libraries even check that value on their own and react to it, sometimes overwriting it, etc. So my experience says this ;)

Yes, all those #ifdef/#else etc. look horrible, but they work.

You are totally right about the copy-paste error and me forgetting static linked Ogre. Stupid mistakes, should have put some more thinking into it. Will fix that tomorrow.

Edit:
Silly mistakes of mine should now be fixed.
My site! - Have a look :)
Also on Twitter - extra fluffy

Post Reply