Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Visual Studio keeps embedding the wrong resource file

I've embedded a resource file (custom type, it's just bytes) into my command line C++ project in Visual Studio, and my rc file points to an absolute path to that bytes file (currently called file.bin in my project directory). However, when I change this bytes file, Visual Studio doesn't always build the exe with the new version of that resource, it will randomly use the old version, even if I clean and rebuild.

How do I force Visual Studio to always re-read file.bin when building?

like image 576
Hex_27 Avatar asked Sep 17 '26 07:09

Hex_27


1 Answers

The problem is that the linker embeds a .res file which is build from the .rc file. Visual Studio does know about the common resources (including images or icon files), but depending the way you have included your binary file, it may have not noticed that the resource file should be compiled each time that file changed. In fact, it correctly processes RCDATA (binary) resources that has been declared directly in the resource editor and are contained in the res folder.

If your binary file has been declared in a different way, it may be necessary to force a resource compilation: just right click on the .rc file and select Compile.

But the correct way would be to use Add resource... and then the Insert... button to include the binary file as a RCDATA resource. That way, the file is automagically included into the project, and the resources are automatically compiled every time the binary file changes.

like image 182
Serge Ballesta Avatar answered Sep 18 '26 21:09

Serge Ballesta



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!