Nominate our 2022 Qt Champions!

how to add flags to the windres call in your .pro file on windows

  • I'm building a Windows 32-bit QT statically linked executable with mingw64 (TDM). If I let qmake do the windres call, it generates the windows resource object file in 64-bit format which then causes the final link to fail. However if I manually call windres first and then run qmake with my .pro file, everything compiles and links correctly. To be clear, these are windows resources (.rc), not QT resrouces (.qrc).

    The fix is simple as I just need to add "-F pe-i386" to the flags on the qmake windres call to generate 32-bit resources, but I can't find any qmake variable to add flags to windres. I expected something like QMAKE_RC_FLAGS to exist.

    I saw QMAKE_RESOURCE_FLAGS, but it's for QT's resources.

    I couldn't find anything in my searches. Any suggestions on how to do it inside the .pro file?


  • Lifetime Qt Champion

    Hi and welcome to devnet,

    if I understand you correctly you are using a 64bit MinGW to cross-compile your application for Win32, right ?

    If so it's probably just the use of the 64bit windres that triggers that by default.

    AFAIK there's currently nothing to add flags or windres. One thing you can try is to modify win32-g++/qmake.conf and add the flag directly to QMAKE_RC.

  • Thanks, that was unexpectedly obvious once you said it. I already had to modify the qmake.conf to add -m32 flags to QMAKE_CFLAGS & QMAKE_LFLAGS but didn't even think to look for the windres command itself. Tested it and your suggestion worked perfect.

    Thanks for the prompt reply.

  • Lifetime Qt Champion

    You're welcome !

    I don't know if there's already something in the mkspecs to cross-compile from 64bit MinGW to 32bit but there's an example in the qmake.conf file from the win32-g++ mkspec that could be of interest.

Log in to reply