RCM is a lightweight C++17 library that embeds binary resources (files, strings, images, etc.) directly into your executable and provides a simple, cached interface to load them at runtime.
- Windows uses native Win32 resources (
.rcfile) – resources are embedded in the PE resource section. - Other OS (Linux, macOS, etc.) generates a
.h/.cpppair containing byte arrays of the files – resources are linked as plain data.
The manager caches loaded resources so repeated requests are instant.
- ✅ Embed any file as a resource (binary or text)
- ✅ Cross‑platform API: same
RCM::Read()call on all OS - ✅ Automatic caching – load once, reuse many times
- ✅ Convenience wrappers:
ReadChars()→std::vector<char>,ReadString()→std::string - ✅ No external dependencies beyond the C++ standard library
You run a resource compiler tool (not included – see “Integration” below) that reads a list of files and generates:
| Platform | Generated files | How it’s linked |
|---|---|---|
| Windows | resources.rc + resource.h |
Compiled by rc.exe and linked into the executable |
| Other | resources.h + resources.cpp |
Compiled and linked directly (byte arrays) |
Each resource is assigned a unique integer ID.
- On Windows:
RCM::Read(id, type)usesFindResourceW/LoadResource/LockResourceto fetch the raw data. - On other OS: the generated
GetResourceData(id, size)function is called, returning a pointer to the embedded byte array.
All successfully loaded resources are stored in an internal unordered_map<int, shared_ptr<VFile>> cache.
- C++17 compiler (tested with MSVC, GCC, Clang)
- The
VFileclass must be defined elsewhere (see below)
RCM expects a simple VFile type with at least:
class VFile {
public:
VFile(); // invalid empty file
VFile(const void* data, size_t size); // copies or references data (implementation defined)
bool isValid() const;
const void* data;
size_t size;
};if you are in windows use this. (if not just use normal add_executable)
add_executable(... ${CMAKE_CURRENT_BINARY_DIR}/${RCM_PROJECT_PATH}/resources.rc)then add the files which you want and then add the project as a subproject
set(RCM_FILES
"id_number|${CMAKE_CURRENT_SOURCE_DIR}/path/to/file"
#example
"4000|${CMAKE_CURRENT_SOURCE_DIR}/Assets/themes.json"
CACHE INTERNAL "RCM resource list"
)
add_subdirectory(thirdparty/RCM)
target_link_libraries(project PRIVATE RCM)