Undefined reference to `_imp__glewInit@0'
Asked Answered
D

3

10

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

Dicks answered 29/7, 2012 at 16:2 Comment(0)
B
23

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.

Bronwen answered 29/7, 2012 at 17:19 Comment(3)
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!Bronwen
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++ XDDicks
Oh my god, where was this post 5 hours ago? One source file... My suffering is finally over!Juieta
E
0

Link glew32 after libs that use it.

Errol answered 29/7, 2012 at 16:4 Comment(7)
If I link it after opengl32 it will produce a bunch of undefined references to wgl functions. I think I've tried all permutations XDDicks
@DavidMaloy Maybe you are using static lib and not declaring GLEW_STATIC?Errol
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.Dicks
@DavidMaloy When using the lib either by -DGLEW_STATIC gcc option, or in code::blocks in "Project build options" -> "Compiler settings" -> "#defines"Errol
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.Dicks
@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.Errol
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.Dicks
C
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 $@
Cornew answered 6/1, 2020 at 9:41 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.