floooh/sokol: standalone C headers for graphics, audio and windowing
minimal cross-platform standalone C headers
At a glance
- What is it?
- Sokol is a set of STB-style single-header libraries for C and C++, wrapping GL, Metal, D3D11, WebGPU and experimental Vulkan behind one 3D API. It suits small native and WASM applications that want a thin layer instead of an engine.
- Who is it for?
- Adopt sokol when you are writing a small C or C++ application that needs a window, a 3D context, audio and async loading, and you want to read the implementation you ship. Do not adopt it if you need a scene graph, an asset pipeline or a GUI toolkit out of the box, because sokol_gfx.h is a resource-level API and the utility headers only cover specific cases such as Dear ImGui, Nuklear, fontstash and debug text.
- Can I use it commercially?
- Yes. Zlib is a permissive licence: you can use, modify and sell software built on it, as long as you keep its copyright and licence notices.
- Is it still maintained?
- Yes. The repository last received commits 2 days ago.
- What is it written in?
- Mainly C, according to GitHub's language statistics.
Answers come from the project's GitHub data, last synced on November 15, 2026, and from our analysis. They are not legal advice.
Star history
- floooh/sokol10,436 ★ · +131
| Repository | 2026-09-22 | 2026-11-15 |
|---|---|---|
| floooh/sokol | 10.3k | 10.4k |
131 Stars in the last 54 days, measured from the daily GitHub snapshot. Compare with other projects
Editorial analysis
What problem sokol solves, and for whom
Sokol is a collection of cross-platform libraries for C and C++, written in C and distributed as standalone headers. The README describes them as "Simple STB-style cross-platform libraries", which is the whole design brief: you copy a header into your project, define an implementation macro in one translation unit, and link against the platform libraries you already use. There is no build system to adopt and no runtime to install.
The audience is narrow and specific. It is for people writing small native applications and games who want a window, a 3D context, input, audio playback, timing and asynchronous loading, but who do not want an engine. The core set is sokol_gfx.h (a 3D-API wrapper over GL/GLES3/WebGL2, Metal, D3D11, WebGPU and experimental Vulkan), sokol_app.h (entry point, window, 3D context and input), sokol_time.h, sokol_audio.h, sokol_fetch.h, sokol_args.h and sokol_log.h. Everything else in the repository is a utility header layered on top.
The README lists real projects built this way, including a Doom shareware port, several demo-scene productions, a Pacman clone in C99, a Lua game framework called Soluna, and two games released on Steam. That list matters more than any feature table: it shows the headers survive contact with shipping software, including a WASM build of the samples on the project homepage.
How the headers fit together: sokol_gfx.h, sokol_app.h and the glue
The architecture is a small dependency graph rather than a framework. sokol_gfx.h owns resources and draw calls. It is a thin wrapper over the platform 3D APIs, and the README names the supported ones directly: GL/GLES3/WebGL2, Metal, D3D11, WebGPU and Vulkan (experimental). sokol_app.h owns the platform entry point, the window, the 3D context and input. sokol_glue.h is the piece that connects the two, because sokol_gfx.h needs to know how to obtain a context and sokol_app.h is only one possible provider.
That separation is the reason the headers are usable outside their own app framework. If you already have a window and a GL context, you can use sokol_gfx.h alone and supply the glue yourself. The utility headers follow the same pattern: sokol_imgui.h is a sokol_gfx.h rendering backend for Dear ImGui, sokol_nuklear.h does the same for Nuklear, sokol_gl.h is an OpenGL 1.x style immediate-mode API on top of sokol_gfx.h, and sokol_fontstash.h is a sokol_gl.h backend for fontstash. Each one plugs into the layer below it instead of duplicating it.
Two smaller headers are easy to overlook but shape the data flow. sokol_fetch.h streams data asynchronously from HTTP and the local filesystem, which is what makes the same loading code work on native and web builds. sokol_args.h parses command-line arguments and URL arguments through one interface, so a web build can read its configuration from the query string while a native build reads it from argv. sokol_log.h provides a standard logging callback for the other headers, which is how you get consistent diagnostics without wiring a logger into each one.
Installing sokol and running a first window
There is no package manager step. The README points at the sokol-samples repository for "How to build without a build system", which is the documented path for integrating the headers into your own project with your favourite C/C++ build system. The practical approach is to vendor the headers you need into your source tree, then define the implementation macro in exactly one translation unit.
The repository root contains sokol_app.h, sokol_gfx.h and sokol_glue.h as plain header files.
Shaders are the other half of the setup. The README links to command line tools in the sokol-tools repository, described as a shader compiler. The samples repository is linked from the README as the place for working examples.
Where sokol is the wrong choice
sokol_gfx.h is a resource-level API. It gives you buffers, images, pipelines, passes and draw calls. It does not give you a scene graph, a material system, an entity component system, an animation system or an asset pipeline. If your project needs those, you are building them yourself, and that is a deliberate cost of using a header set this thin.
The utility headers cover GUI only through specific integrations. Dear ImGui and Nuklear have rendering backends in util/, and sokol_debugtext.h renders text using vintage home computer fonts. There is no general text layout or widget library in the core. A project that needs a rich settings screen, localisation and font fallback will spend its time in sokol_fontstash.h and fontstash rather than in sokol itself.
Platform coverage is defined by the backends the README names: GL/GLES3/WebGL2, Metal, D3D11, WebGPU and Vulkan (experimental). If you vendor the headers, the update story is whatever your own repository does with the files you copied.
Finally, behaviour can change in ways that touch applications. The README's "See what's new" link points at CHANGELOG.md, and the README's latest note, dated 01-Nov-2026, says the swapchain during window resize now works in the sokol_app.h Windows backends. Read the changelog before updating.
sokol vs SDL: two different layers
SDL is the natural comparison, and the difference is architectural rather than a matter of features. SDL is a platform abstraction library with a stable ABI, a shared or static library you link against, and a broad surface that includes windowing, input, audio, threads, filesystem access and more. Sokol is a set of headers you compile into your program, with no shared library and no ABI to maintain.
That difference has practical consequences. With SDL, updating the library is a link-time change and applications keep running against the new binary. With sokol, updating means replacing the header files in your tree and recompiling, which is simpler to reason about but puts the diff in your repository. The other consequence is scope: SDL is mainly a platform layer, so a project using it for windowing typically chooses a rendering layer separately. sokol_app.h and sokol_gfx.h are designed as a pair, and sokol_glue.h exists precisely to join them without a third dependency.
The choice usually comes down to what you already have. If your codebase is built around SDL and its ecosystem, adding sokol_gfx.h on top is a reasonable move because the glue is a single header. If you are starting from nothing and want the smallest possible dependency surface, sokol's compile-in model avoids a library dependency entirely.
Licence, maintenance and upgrade cost
Sokol is released under the Zlib licence, which is a permissive licence that permits use in closed-source software. That is a practical advantage over copyleft alternatives for commercial projects, but it is not legal advice, and the LICENSE file in the repository root is the text that governs your use. Read it rather than a summary of it.
The repository is not archived, and the last push was on 2026-11-02. The README's changelog link carries a dated note for 01-Nov-2026, which indicates the headers are still being adjusted. The repository has no published releases, so the practical upgrade mechanism is the changelog plus the header diff in your own tree.
The upgrade cost is real but bounded. Because the headers are vendored, an update is a file replacement followed by a recompile, and the changelog is the only migration document the project points to. The samples repository and the WASM sample page are the reference for expected behaviour after an update. If you pin a copy and never look at CHANGELOG.md, you will not learn about changes such as the Windows swapchain-resize one until something breaks.
Editorial conclusion
Adopt sokol when you are writing a small C or C++ application that needs a window, a 3D context, audio and async loading, and you want to read the implementation you ship. Do not adopt it if you need a scene graph, an asset pipeline or a GUI toolkit out of the box, because sokol_gfx.h is a resource-level API and the utility headers only cover specific cases such as Dear ImGui, Nuklear, fontstash and debug text. Before committing, verify which backends your targets need (GL/GLES3/WebGL2, Metal, D3D11, WebGPU, experimental Vulkan), confirm that the shader compiler in sokol-tools supports your shading language, and check CHANGELOG.md, whose latest README note (01-Nov-2026) covers swapchain behaviour during window resize in the sokol_app.h Windows backends.
Frequently asked questions
What is the sokol library?
It is a set of STB-style standalone C headers for C and C++, described in the README as simple cross-platform libraries written in C. The core headers cover a 3D-API wrapper, an app framework, time measurement, audio playback, asynchronous fetching, argument parsing and logging.
How do you use sokol in a C or C++ project?
You vendor the headers you need and define SOKOL_IMPL in one translation unit before including a header such as sokol_app.h, then include the others without the macro. The README points to the sokol-samples repository for how to build without a build system, and to sokol-tools for the shader compiler.
How does sokol compare with SDL?
SDL is a platform abstraction library you link against, while sokol is a set of headers you compile into your program. sokol_gfx.h and sokol_app.h are designed as a pair joined by sokol_glue.h, and the README lists GL/GLES3/WebGL2, Metal, D3D11, WebGPU and Vulkan (experimental) as the 3D backends.
Official sources
Add this badge to your README
If you maintain this project, the badge below links readers to this analysis and shows its maintenance status from the daily GitHub snapshot. Paste the markdown into your README; add ?metric=license or ?metric=stars to the image URL for a different field.
[](https://hysenlabs.com/projects/floooh-sokol)Star history chart for your README
[](https://hysenlabs.com/projects/floooh-sokol)Was this useful?