Im currently having troubles setting up OpenGL with my system. Im using codeblocks and have added SDL2, GLEW, and GL to the linker libraries. I installed these three using apt-get with no problems. When I try to build I get the output:
ld||cannot find -lGL|
I don’t really know much except that i think it is looking through /usr/lib/ld. Here is some graphics info, just in case it is relevent to the problem somehow:
I’m hoping that this is a really common problem with a simple solution and that the search engine gods just haven’t been nice to me. If this isn’t the case and you need more info, I’ll be happy to give it.
That’ll tell you where your GL library lives. Most likely /usr/lib64 (64-bit) or /usr/lib (32-bit).
Then point your linker to that library, either explicitly with a full path to the library, or by adding a library search path with -L.
However, typically you don’t need to do that because 1) the GL library is in a system library directory, and 2) that directory is searched by ld by default (unless somebody’s overriden that behavior with -nostdlib.
Typically, shared libraries have 3 filenames: the actual file has a name which includes the complete version number (e.g. libGL.so.1.2.0), then there’s a symlink which only includes the major version number (e.g. libGL.so.1) and another which doesn’t contain any part of the version number (e.g. libGL.so).
The library name stored in the executable uses the name with the major version number, so that you can upgrade to a newer minor version without needing to re-link the executable. A different major version number normally indicates some form of incompatibility, so executables compiled for one major version shouldn’t attempt to use a different major version.
The (compile-time) linker uses the name without any version number. E.g. -lGL will cause the linker to look for libGL.so or (if that isn’t found) libGL.a.
Because the symlink without the version number is only needed for compiling, and not for running programs which use the library, it’s often part of a separate “-devel” package (e.g. “opengl-devel” or similar) which must be installed separately from the package containing the library.