Here's an example https://github.com/glfw/glfw/blob/master/include/GLFW/glfw3.h#L231
Hah, good timing :) Just wanted to add a ticket myself.
Here's what it would look like:
https://github.com/floooh/sokol/blob/7c88e7736e813479595489bb6acaa373d25fd1f8/sokol_gfx.h#L489-L497
You'd just define SOKOL_DLL both when building and using the DLL. When building the DLL (SOKOL_IMPL is also defined) it will use __declspec(dllexport), otherwise __declspec(dllimport).
I need to do this for all headers, and actually test on Windows before merging, might take a few days.
Sounds just right!
FYI, I did something similar under Windows 10 x64 (MSVC 2017), and it works like a charm for sokol-gfx!
New sample code to test building and using sokol as DLL (currently Windows only):
sokol-dll.c implementation file:
https://github.com/floooh/sokol-samples/blob/dll-defines/libs/sokol/sokol-dll.c
fips/cmake definition to create the DLL:
And an executable using sokol as DLL (note the SOKOL_DLL define, that's the only difference):
https://github.com/floooh/sokol-samples/blob/dll-defines/sapp/noentry-dll-sapp.c
fips/cmake definitions:
...and the imports/exports via dumpbin, just to make sure it actually works :)
> dumpbin /exports sokol-dll.dll:

The sokol-dll.dll depends on kernel32.dll, user32.dll, ole32.dll and d3d11.dll (with d3dcompiler_47.dll loaded on demand).
> dumpbin /imports noentry-dll-sapp.exe

The exe only depends on kernel32.dll and sokol-dll.dll.
Currently this is still all in a branch, and only the "main headers" are working. Next I'll update the headers in the util directory too, and merge to master.
Ok, everything done and merged. It may also make sense to add function pointer typedefs, for situations where the DLL is loaded manually via dlopen or LoadLibrary, but I'll wait with this until anybody actually needs it :)
Most helpful comment
Here's what it would look like:
https://github.com/floooh/sokol/blob/7c88e7736e813479595489bb6acaa373d25fd1f8/sokol_gfx.h#L489-L497
You'd just define SOKOL_DLL both when building and using the DLL. When building the DLL (SOKOL_IMPL is also defined) it will use __declspec(dllexport), otherwise __declspec(dllimport).
I need to do this for all headers, and actually test on Windows before merging, might take a few days.