What's up guys,
How do I go about statically linking libraries, like SDL2, so I can have them alongside my binary for distribution?
There are pros and cons to static linking. Its great for small libraries but can be cumbersome for larger ones. Its cool when your .exe file has no .dll next to it, but for most part users do not care. Statically linking is best when you can just nimble install foo and not have to worry about hunting down foo.dll.
It looks like SDL supports static linking just follow the instructions in the readme: https://github.com/nim-lang/sdl2#static-linking-sdl2
If library does not support static linking you would need to add support for this. Usually this is simply just making a soft-of-a-make file with nim's pragmas instead. Just include the right c/c++ files for your platform with {.compile.} pragmas and other switches. See how I statically linked glfw here: https://github.com/treeform/staticglfw/blob/master/src/staticglfw.nim#L4-L88
I hope this helps.
const path = when defined(windows): "path/to/mylib_windows.a" elif defined(macosx): "path/to/mylib_macos.a" elif defined(linux): "path/to/mylib_linux.a" switch("passL", path)