Question

Like the title says, I'm getting multiple build errors using C::B, all are saying undefined reference to '*'. I'm trying to build a program using OpenGL, GLFW, and GLEW. The top three things that it cant find every time are _imp__CreateDCW@16, _imp__GetDeviceCaps@8, _imp__DeleteDC@4. When looking on the internet, I saw that all of those methods were in the gdi32 library, which I made sure to add to the linker. The error appears to be happening as soon as I try to use methods from GLFW3. I've tried using different builds of GLFW using MinGW, which is what I'm using with Code::Blocks, but I cannot get the error to go away.

I am developing on Windows 8.1, using Code::Blocks 13.12.

Here is a list of everything I am linking and in the same order:

  • gdi32
  • kernel32
  • user32
  • opengl32
  • glu32
  • glfw3

Code::Blocks is turning out to be a bit of a hassle, but I really want to start to get used to it. Thanks to anyone who can help.

Was it helpful?

Solution

You've to pass -lgdi32 for the linker to know that you're using GDI functions. Also the order matters. On Windows 8 with MinGW 4.8.1 tool chain I give this:

  • glew
  • glfw3
  • opengl32
  • gdi32

And it works for me; I don't include the other win32 libraries. If you're using GLEW's static library make sure you define GLEW_STATIC either in CB or directly as -DGLEW_STATIC.

As for the IDE, I chose QtCreator with CMake and with no Qt SDK.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top