Search code examples
c++windowsopengllinkerlibraries

ld.exe cannot find -lGL


I have recently bought a book on OpenGL and am trying to follow the examples, but I can't get to seem OpenGL to work.

For example, it gives me the error:

ld.exe||cannot find -lGL|.

My compiler is GNU-GCC MinGW on with the IDE Code::Blocks, and my OS is Windows 7 64 bit. I have linked the libraries: opengl32, glu32, glut32, and in other linker options I have: -lmingw32 -lSDLmain -lSDL, because this was advised on the code::blocks wiki.

I have some experience with C++, but not at all when it comes to linking, and setting up the compiler, because this used to go quite automatic.

How do I fix this error?


Solution

  • The flag -lGL is to link to the opengl library, but on Windows the opengl library is called opengl32, not libgl. So you shouldn't use -lGL and if you're already linking in opengl32 then that should be all you need.