9

I have built the glew lib so many times. My last build removed the undefined references to all the shader functions such as glCreateShader(). I think this build is the correct one cause I found out that Code:Blocks can open Visual Studio 6.0 projects so it had everything laid out for me.

I can compile my app without calling glewInit() but it results in a SEGFAULT right when glCreateShader() is called. Which is caused by not Initializing glew.

I need to turn it on but it wont let me XD

links: mingw32, glew32, opengl32, glu32, glut32

IDE: Code::Blocks

Compiler:MinGW32

Himanshu
  • 31,810
  • 31
  • 111
  • 133
Kaliber64
  • 586
  • 1
  • 5
  • 16

3 Answers3

22

Save yourself a lot of trouble and just add the glew.c to your project directly. I do not understand why people fight so hard to link to it externally. The license is friendly, and it is only one source file. Just remember to #define GLEW_STATIC.

TheBuzzSaw
  • 8,648
  • 5
  • 39
  • 58
  • 1
    I'm genuinely curious: why not? Why would you rather try to link to it as an external library? Making a DLL just adds another run-time dependency, and making a static library... well, you just add the one file. Haha! – TheBuzzSaw Jul 30 '12 at 03:20
  • Well for organization sake its easier the less files that don't change I have in my project cause I'm bad. But I recently had to do the same thing with an image loader XD. soooo... I can't have what I want. Especially in c++ XD – Kaliber64 Jul 31 '12 at 00:22
  • 1
    Oh my god, where was this post 5 hours ago? One source file... My suffering is finally over! – Joseph Thomson May 11 '13 at 15:23
0

Link glew32 after libs that use it.

yuri kilochek
  • 12,709
  • 2
  • 32
  • 59
  • If I link it after opengl32 it will produce a bunch of undefined references to wgl functions. I think I've tried all permutations XD – Kaliber64 Jul 29 '12 at 16:06
  • 1
    @DavidMaloy Maybe you are using static lib and not declaring `GLEW_STATIC`? – yuri kilochek Jul 29 '12 at 16:07
  • Where exactly do I put that. When making the lib? or at the top of a header? or in the compiler options. I have tried but idk if I tried the correct places. – Kaliber64 Jul 29 '12 at 16:10
  • @DavidMaloy When using the lib either by -DGLEW_STATIC gcc option, or in code::blocks in "Project build options" -> "Compiler settings" -> "#defines" – yuri kilochek Jul 29 '12 at 16:14
  • Well I don't know what a gcc option is so. Do i type #define GLEW_STATIC or just GLEW_STATIC in the box because no matter what I type it doesn't error so it wont tell me if somethings wrong. – Kaliber64 Jul 29 '12 at 16:17
  • @DavidMaloy Its supposed to be just `GLEW_STATIC` but ensure that you set it for the while project and not just one of the build targets (in the list on the left), or it can be just one build target but make sure you build this target and not the other one. – yuri kilochek Jul 29 '12 at 16:23
  • The problem persists. glewInit() has to be called after the OpenGL context is opened but I think that would result in a runtime error otherwise. I have the glew functions except the init. I dont get it. – Kaliber64 Jul 29 '12 at 16:29
0

In Ubuntu 18.04 to work OpenGL the GLEW should be installed:

apt-get install libglew-dev   

And it works when add linker option: "-lGLEW" to linker call, like in the Makefile for the FLTK:

...
# HOW TO LINK
.o$(EXEEXT):
  @echo "*** Linking $@..."
  $(CXX) $< $(LINKFLTK_ALL) -lGLEW -o $@
Alex
  • 1,297
  • 1
  • 16
  • 12