1

Sorry if the title is confusing. Anyways I'm working on a small game engine in C++ and I want to modularize it. I want there to be a core module and then you can install other modules based on what your using (2D Graphics, 3D Graphics, Audio, Physics, etc) and I was thinking the best (maybe only) way to do this is make each module another project in my VS solution that compile to dlls while the core is a lib. The core lib could check which modules are installed by checking for a macro like ENGINE_2D_GRAPHICS_MODULE that could be defined in the dll. How would I do this and is there a better way? I'm pretty sure there's probably a better way but idk what it is.

PlanetVaster
  • 507
  • 1
  • 6
  • 18

1 Answers1

2

Macros are compile-time constants, you can't influence your core module this way upon installing new modules. You probably want to detect whether additional modules are present in the filesystem and then load them with LoadLibrary (on Windows) or dlopen (on POSIX-conforming systems).

A different option would be to let the game developer (i.e. the the engine user) to link your library statically and, respectively, compile only the needed parts.

Roman
  • 36
  • 1