OpenGL isn't a libraryand DirectX aren't libraries in the traditional sense (as in "library is a set of functions") , it's a definition. Instead of implementing the functions, they just declared what manufacturers need to implement to support OpenGLthem. That's, why graphics card support a certain OpenGL version, and not the other way around.
So, with this it should be much clearer what OpenGLthey actually doesdo. ItThey just tells the GPU driver what to do, but not how exactly. Same with shader compilation, OpenGL just sendsthey send the source to the driver, which compiles it.
Technically, you could pre-compile every shader, but you would be trading a ton of storage space for little performance, especially since shaders get compiled before gameplay