Undefined refernce to GetModuleHandleEx

Help
futska
2013-09-27
2013-09-27
  • futska

    futska - 2013-09-27

    I am using MinGw/msys/gnuwin32 to compile zbar 0.10 under Win7x86. I keep getting the following error:

    zbar/processor/.libs/zbar_libzbar_la-win.o: In function zbar_processor_open': C:\msys\1.0\local\src\zbar-0.10/zbar/processor/win.c:269: undefined reference toGetModuleHandleEx'

    collect2.exe: error: ld returned 1 exit status
    make[1]: *** [zbar/libzbar.la] Error 1
    make[1]: Leaving directory `/usr/local/src/zbar-0.10'

    I read the thread about changing GetModuleHandleEx to GetModuleHandle to support Win2k. Does that apply here? Shouldn't I be able to link to /mingw/lib/libkernel32.a for GetModuleHandleEx?

    Thanks

     
  • affe chen

    affe chen - 2017-04-28

    Hello,

    Now it is 2017, and I ran into exactly this same problem.
    What I found is this: the configure script will generate:

    #define _WIN32_WINNT 0x0500
    

    in include/config.h

    While in mingw/include/winbase.h:

    #if (_WIN32_WINNT >= 0x0501)
    WINBASEAPI BOOL WINAPI GetModuleHandleExA(DWORD,LPCSTR,HMODULE*);
    WINBASEAPI BOOL WINAPI GetModuleHandleExW(DWORD,LPCWSTR,HMODULE*);
    #endif
    

    means only when _WIN32_WINNT >= 0x0501, will GetModuleHandleExA() and GetModuleHandleExW() be defined.

    My solution is to make change to include/config.h:

    #define _WIN32_WINNT 0x0501
    

    and it will go.

    Maybe there is a better way to let configure script recognize correct Windows version. But I did't not look into this way.

     

Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

JavaScript is required for this form.





No, thanks