This Visual Studio solution contains two projects: enginelib
and hotreload
. enginelib
is a DLL project that includes the functionalities you want to hot reload. hotreload
is an executable project that demonstrates how to dynamically load, unload, and reload the enginelib
DLL at runtime. This setup is particularly beneficial for C++ development on Windows, where iterative testing and development are crucial, such as in game development.
- Dynamic DLL Loading: Load and unload the
enginelib
DLL at runtime in thehotreload
executable. - Automatic Reloading: The
hotreload
executable watches for changes in theenginelib
DLL and reloads it automatically. - Error Handling: Implements basic error handling for file access and DLL operations.
- Windows Operating System
- Visual Studio 2022 or later (solution is set up and tested with Visual Studio 2022)
- C++17 Compiler (for
std::filesystem
support)
enginelib
: The DLL project. Contains the code that can be hot reloaded.hotreload
: The executable project. It loads theenginelib
DLL and implements the hot reloading mechanism.
-
Clone the Repository:
git clone https://github.com/andresfelipemendez/hotreload.git
-
Open the Solution in Visual Studio: Navigate to the cloned directory and open the solution file.
-
Build the Projects: Build both the
enginelib
andhotreload
projects within Visual Studio. -
Run the
hotreload
Executable: Start thehotreload
project. It will load theenginelib
DLL. -
Modify and Rebuild the
enginelib
DLL: Make changes to theenginelib
project, rebuild it, and observe thehotreload
application reloading the DLL without needing a restart.
- Ensure that both
enginelib
andhotreload
projects are built with compatible settings (e.g., Debug/Release, x86/x64). - The hot reloading mechanism uses simple file polling to detect DLL changes. Adjust the checking interval in the
hotreload
project as needed. - While the example provided is basic, it's a starting point for more complex implementations, and additional error handling might be required for production-grade applications.
Feel free to fork this repository, make improvements, and submit pull requests. Any contributions to enhance this hot reloading solution are welcome.