1

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.

sm81095
  • 290
  • 1
  • 6
  • 18

1 Answers1

1

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.

legends2k
  • 31,634
  • 25
  • 118
  • 222
  • Thanks! This appears to have fixed the compiler error, but now when I try to run it I get the following error: http://i.imgur.com/PCSUSe7.png. This error seems to be coming from either an old version of GLEW, or a missing glew32.dll. I've tried placing glew32.dll in the same location as my executable, and tried replacing the glew32.dll in my System folder with the newer one, but this error persists. Also you are like the 10th person I've talked to who has recommended QtCreator, so I guess I'll take a look at it. – sm81095 Apr 03 '14 at 16:13
  • That's because you're using GLEW's dynamic library. Put `glew32.dll` in the same directory as your `.exe`. It should solve it. However, if you don't wanna do that then you've to use GLEW's static library; usually it's in the name `glews` or `glew32s`. If you're going for the static library, make sure you define `GLEW_STATIC`. – legends2k Apr 03 '14 at 16:55
  • I tried to put the .dll in the same directory, but that didn't help. I just decided to link it statically, and that solved the problem, thanks. – sm81095 Apr 03 '14 at 19:59