Important: Please read the Qt Code of Conduct -

Qt cannot find constants into an included header <SOLVED>

  • I am trying to build an application in Windows 7 with MinGW that uses


    I get an undefined reference for these, although I can clearly see them inside ShlDisp.h and Qt does auto-fill them when I start typing them.

    I have included ShlDisp.h and linked to shell32 (according to
    @#include <ShlDisp.h>@

    In my .pro file:

    @LIBS += -lshell32 -loleaut32 -lole32@

    The final command executed seems to be:

    @g++ -Wl,-subsystem,windows -mthreads -o debug\wallch.exe object_script.wallch.Debug -lglu32 -lopengl32 -lgdi32 -luser32 -lmingw32 -lqtmaind -lshell32 -loleaut32 -lole32 -LC:\Qt\Qt5.2.0\5.2.0\mingw48_32\lib -lQt5Widgetsd -lQt5Networkd -lQt5Guid -lQt5Cored@

  • Moderators

    A quick objdump run sheds some light on the matter.
    In Windows SDK IID_IShellDispatch is defined inside uuid.lib and it needs to be linked to work (MS documentation seems to miss this information).
    Mingw provides its own copy of windows sdk libs and headers and although it's declared in shldisp.h as external, it's not actually defined in any of the libs, not even in libuuid.a. I don't know if it's a bug of theirs or just the pre-built packages are misconfigured, but that's how it is.

    So my advice would be to install the MS Windows SDK and link to the libs from there by
    LIBS += -L"Path to SDK" -lshell32 -luuid
    Mingw doesn't seem to mind linking to .libs from there.

  • Thanks :) This solved it!

    Final line into the .pro file is:

    @LIBS += -L"C:\Program Files\Microsoft SDKs\Windows\v7.1\Lib" -loleaut32 -lshell32 -luuid -lole32@

Log in to reply