Home > Software design >  Is there a way to create a resource-only DLL using mingw compiler tools?
Is there a way to create a resource-only DLL using mingw compiler tools?

Time:11-02

It is possible with MSVC to create a so-called resource-only DLL which essentually is a DLL that contains no machine code, but only resources. Is there a way to create a DLL only resource file using mingw? (If not possible, is it possible using open source tools?)

I know you can use windres to compile rc files into .res files. But the resources are appended with the compiler. but what if I have nothing to compile?

CodePudding user response:

windres documentation says you can compile resources to coff object format and link it:

The normal use is for you to write an rc file, use windres to convert it to a COFF object file, and then link the COFF file into your application.

If the input or output format is not specified, windres will guess based on the file name, or, for the input file, the file contents. A file with an extension of .rc will be treated as an rc file, a file with an extension of .res will be treated as a res file, and a file with an extension of .o or .exe will be treated as a coff file.

So, e.g. with my.rc:

1 BITMAP "Untitled.bmp"

You can build it into dll by invoking:

windres -i my.rc -o my.o
ld --dll -o my.dll my.o
  • Related