> For the complete documentation index, see [llms.txt](https://azuriohs-organization.gitbook.io/r-type/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://azuriohs-organization.gitbook.io/r-type/subsystems/create-your-subsystems/step-4-load-your-subsystems-in-the-client.md).

# Step 4 - Load your subsystems in the client

In this step, we will integrate your subsystem into the client application by loading it appropriately. This step ensures that your subsystem is active and can perform its designated functions within the ECS architecture. This typically involves dynamically loading the subsystem's shared library and initializing it.

***

## 🧑‍💻 Load Your Subsystem

To load your subsystem, you will need to use dynamic loading functions provided by your operating system. Below is an example of how to do this in C++ using `dlopen` and `dlsym` on Unix-like systems.

> You can use our `DLLoader` class to simplify this process.

```cpp
#include "LibraryLoader/DLLoader.hpp"
#include "IExampleSubsystem.hpp"

void loadSubsystem() {
    try {
        // Create a DLLoader instance for your subsystem
        auto& loader = LibraryLoader::DLLoader<IExampleSubsystem>::GetInstance();

        // Initialize the loader with the path to your subsystem's shared library
        loader.InitLibrary("path/to/your/subsystem/library");

        // Get the instance of your subsystem
        IExampleSubsystem* subsystem = loader.GetLibraryInstance();

        // Now you can use your subsystem
        subsystem->Initialize();

        // Don't forget to call shutdown when done
        subsystem->Shutdown();

    } catch (const std::exception& e) {
        std::cerr << "Error loading subsystem: " << e.what() << std::endl;
    }
}
```

> Once it's done, you have successfully loaded your subsystem in the client application. You can now proceed to use it as needed within your ECS framework.
