QT 4 and Custom Manifests for Windows Executables

There does not seem to be much of an easy way to add a custom Windows manifest for EXE’s created using QT 4.8.3 on Windows. Win SxS and execution levels for UAC can be easily set, but we also need to pay attention to the application compatibility settings for Windows Visa, 7, and 8. Now, I am not a QT guru, and I am learning a lot more about this development tool as I go on.

After a bit of poking around, it seems that qmake uses C:\Qt\4.8.3\mkspecs\features\win32\embed_manifest_exe.prf as a template for generating the instructions to embed the manifest in the resulting nmake based Windows makefile. Delving into this file, we find that only one manifest file is passed to mt.exe for generating the embedded manifest. This manifest file is the manifest file generated by the /MANIFESTUAC, /MANIFESTDEPENDENCY linker options. We need to add a partial manifest file to include the application compatibility settings.

The best solution for this is to handle the manifest embedding step yourself. Adding the following to the top of the .PRO file

CONFIG -= embed_manifest_exe

Tells qmake not to use the embed_manifest_exe.prf for the generated make file. Note, if this is a DLL, embed_manifest_exe becomes embed_manifest_dll. To embed the manifest yourself, use something like the following in your .PRO file:

win32:CONFIG(release, debug|release) {
QMAKE_POST_LINK = $$quote(mt.exe -nologo -manifest \"WinCompat.manifest\" \"release\\MyProgram.exe.manifest\" -outputresource:$(DESTDIR_TARGET);1)
else:win32:CONFIG(debug, debug|release) {
QMAKE_POST_LINK = $$quote(mt.exe -nologo -manifest \"WinCompat.manifest\" \"debug\\MyProgram.exe.manifest\" -outputresource:$(DESTDIR_TARGET);1)

The WinCompat.manifest file contains the compatibility settings for the embedded manifest.


[source language=”xml”]
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
<compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
<!–The ID below indicates application support for Windows Vista –>
<supportedOS Id="{e2011457-1546-43c5-a5fe-008deee3d3f0}"/>
<!–The ID below indicates application support for Windows 7 –>
<supportedOS Id="{35138b9a-5d96-4fbd-8e2d-a2440225f93a}"/>
<!–The ID below inidcates application support for Windows 8–>
<supportedOS Id="{4a2f28e3-53b9-4441-ba9c-d69d4a4a6e38}" />

Enjoy the freedom an bliss from the nagging of the Windows Compatibility Assistant or whatever that thing is.

This entry was posted in QT 4, Windows 8 and tagged , . Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *