Using SDL as a part of a static library in Visual Studio 2022

Hello All,
I want to create a static library that uses SDL as a part of it. I’m using Visual Studio 2022. I have followed the guides with configuring the project properties and I am at a point where the library builds successfully. However, when I try to use the library inside of an application project, I get the error:

C1083 Cannot open include file: ‘SDL.h’: No such file or directory

I’m not entirely sure what I’m missing. Is anyone able to point me in the right direction for what I want to do?

I assume that the error message is refering to a h/cpp file in the project that’s using the static library and not in some file inside the static library.
Your project doesn’t know about the SDL library that your static library uses so you need to include SDL.h in the file(s) the error message refers to.

So in your project, add include- and lib paths to SDL and then do "#include “SDL.h” in the h/cpp file(s) that has the error message.

This is a project management issue.

If you only use SDL inside your static library and don’t want your library user to use SDL, do not #include SDL header files in your library’s header files. Otherwise your library user would also have to locate SDL header files.

If you really want your library user to use SDL (for example you are using SDL types in your library’s public API), you have to add SDL’s include path in your library so that your library user knows where to find SDL header.