Skip to content
Advertisement

How to dynamically check for library information in posix compliant systems in C++?

I am playing around with Linux to learn some things about operating systems. Currently I want to query the OS for the version of certain libraries (GLFW and GLEW on particular). I want to print the current version or a message if the library is not installed.

Is there a general way to query the OS for the version of an installed library?

Advertisement

Answer

It is library-specific. Each library will have its own method (or might have none) to query what version is loaded.

This is different to querying the system to ask what version of a library is installed–that’s the wrong way to go about it because the version loaded in your program might be different to what the system has installed (and the system might have multiple runtime versions installed).

In your specific case, you need to call glfwGetVersion() for GLFW, and use GLEW_VERSION for GLEW.

User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement