help me understand, umm, static compilation?

OPEN

Could someone help me understand something I heard about once where you can compile your program so that it doesn't depend on external libraries from the end-users perspective. As an example, say I develop a game using GLFW and the OpenGL 3 API. Is it then possible to utilize this static compilation principle so that my binary can be run on a computer which does not have GLFW installed?

Posted Oct 28, 2019, 9:49 PM UTC

24
ggchappell•

What you're talking about is static linking. How it is done depends on OS, build system, and often which library you're talking about. u/alfps linked to instructions for GLFW; other libraries may be handled differently. (But at least now you have something to Google.)

3
frontonthisOP•

I still don't understand why some things are and aren't possible to be statically linked, and how much can b...what's the smallest assumption you could make about a user's operating system, even if your binary has to the the size of an OS

2
ggchappell•

If you have all of the source code, then you can do static linking. The issue is that some packages are not distributed as source code, but only as pre-compiled library files. When we use such packages, our options may be limited.

2
alfps•

Some libraries are only offered as dynamic libraries. Happily it appears that GLFW can be linked statically. Check out their documentation.

2