0
votes

Issues with joining .rc/resource.h files

So I have been working on this issue for the last 4 days and I can't seem to find an answer that works. I have found some older resources on how to do this but can't find how to do this in VS2015.

I am building an MFC Ribbon Application that extends the nominal Office2007 theming with a static lib. The problem is that I want to store the resources within the lib and not within the project itself as I want to reuse this lib later with minimal overhead. I know that the theming code works perfectly because when you move the resources declarations from the lib .rc and resource.h files and put them in the projects .rc/resource.h files the libs functions work perfectly.

I know the pathing is correct within the project settings because the program compiles without warnings or errors. When you step through the code line by line when my custom theme is activated it breaks when looking for the Style.XML file.

I have gotten as far as including my lib's .rc/resource.h files within my main project's .rc file and I have added the correct path to the resources in the Configuration Properties/Resources/General/Additional Include Directories.

This, however, doesn't seem to have worked as when I unpackage the resulting .exe the resources aren't in there.

Tl;Dr How do you link/include .png/.xml resources from a static lib to an MFC project?

link to the resource I used to get this far

Any help is appreciated! Thank you!!

1
A static library cannot contain resources. The .lib file format simply doesn't have a provision for that. You should be able to compile your .rc file to .res, and link with that.Igor Tandetnik
I should clarify. The lib project has its own .rc and resource.h file that allows me to embed resources into that project. From what I understand I need to link these to the main project separately as well as linking the .lib file. The problem is they just aren't coming through once I follow the instructions on the link I included in my original post.Aubrey H.

1 Answers

0
votes

So I've now solved this issue. It turns out that my lib projects .rc file wasn't being correctly compiled into a .res file. Once I deleted the offending .rc file from my project directory and rewrote it from scratch it compiled properly. As soon as I did this and did a clean/rebuild on the whole solution it started working again and now the resources appear properly within the .exe and my custom theming works!

Basically, the process outlined in the link I included in the original question works as specified unless VS decides not to do its job properly!

If anyone else runs into this issue. Unpack your .res files using a third-party resource editor and make sure that they are compiling properly. This issue is a silent time killer!