Adding a manifest to gcc-compiled .dll that links to msvcr90

November 10, 2010 by · Leave a Comment
Filed under: Notes 

First, create a manifest file, called $(DLLNAME).dll.manifest
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
<security>
<requestedPrivileges>
<requestedExecutionLevel level="asInvoker" uiAccess="false"></requestedExecutionLevel>
</requestedPrivileges>
</security>
</trustInfo>
<dependency>
<dependentAssembly>
<assemblyIdentity type="win32" name="Microsoft.VC90.CRT" version="9.0.21022.8" processorArchitecture="*" publicKeyToken="1fc8b3b9a1e18e3b"></assemblyIdentity>
</dependentAssembly>
</dependency>
</assembly>

Then make a small $(DLLNAME).rc file:

#include "winuser.h"
2 RT_MANIFEST "$(DLLNAME).dll.manifest"

Then compile this using windres in Makefile:

WINDRES = windres.exe
$(DLLNAME).o: $(DLLNAME).rc
$(WINDRES) --input $(DLLNAME).rc --output $(DLLNAME).o --output-format=coff

and link as usual:

$(BIN): $(OBJ) $(DLLNAME).o
$(CPP) $(SHARED) $(OBJ) $(DLLNAME).o $(LINKFLAGS) $(LIBS) -o $(BIN)

Thanks to this site and this one.