Is it possible to build resources into a static library and reuse them by simply linking with the library?
I\'m primarily thinking about the case where you call a fu
As per Visual Studio 2010, the development tools from Microsoft apparently cannot properly handle compiled resource data inside static libraries at all.
To distribute a compiled resource file (a .res
file), you have two choices:
.res
files separately, and instruct the client code to link against them;cvtres
to merge several .res
files into a single object (.obj
) file, and provide it separately.Note that you can't lib in object files created with cvtres
. If multiple object files are provided, lib
complains as though as multiple .res
files were given; if a single object file is provided, lib
does not complain, but the linker simply ignores the embedded resource data in the lib file.
It might be the case that there is a way to force the linker to read and link the libbed in resource data (with some command-line option, section manipulation and so on), since the resource data is indeed available in the library (as dumpbin
reveals). So far, I haven't found a solution, and, unless one is willing to hack the development tools, anything better than this simple solution is probably not worth the effort.
The only way to ship resource data in a static library (in this case, with a static library) is to distribute the resources separately and explicitly link them in the client code. Using cvtres
can reduce the number of distributed resource files to one, if you have many of them.