Undefined reference to glew

5.2k Views Asked by At

while I am working on rendering fonts using ftgl in my opengl project I am encountering errors stating

g++ -o mygame Sample_GL3_2D.cpp glad.c -lGL -lglfw -ldl -lftgl  -lSOIL -I /usr/include/freetype2 -L/usr/local/lib -lfreetype
/usr/local/lib/libftgl.so: undefined reference to `__glewGenBuffers'
/usr/local/lib/libftgl.so: undefined reference to `glewInit'
/usr/local/lib/libftgl.so: undefined reference to `__glewBindVertexArray'
/usr/local/lib/libftgl.so: undefined reference to `__glewBindBuffer'
/usr/local/lib/libftgl.so: undefined reference to `__glewUniform3f'
/usr/local/lib/libftgl.so: undefined reference to `__glewVertexAttribPointer'
/usr/local/lib/libftgl.so: undefined reference to `__glewBufferData'
/usr/local/lib/libftgl.so: undefined reference to `__glewDeleteBuffers'
/usr/local/lib/libftgl.so: undefined reference to `__glewDeleteVertexArrays'
/usr/local/lib/libftgl.so: undefined reference to `__glewGenVertexArrays'
/usr/local/lib/libftgl.so: undefined reference to `__glewEnableVertexAttribArray'

these are my contents in Makefile

all:mygame

mygame: Sample_GL3_2D.cpp glad.c
    g++ -o mygame Sample_GL3_2D.cpp glad.c -lGL -lglfw -ldl -lftgl  -lSOIL -I /usr/include/freetype2 -L/usr/local/lib -lfreetype
clean:
    rm mygame

looks like the errors is being raised by the libftgl.so library. I have installed the GLEW using the glew packages in the ubuntu. but dont understand why it isn't being referenced.

1

There are 1 best solutions below

0
On

You aren't referencing the GLEW library on the compile/link line. The -l flag to g++ is tells it to tell the linker to the link the library e.g. -lftgl tells it to look for the ftgllibrary and link it.

You don't have -lGLEW (or -lglew if the library is named using lowercase) so it isn't linked. Also see this answer error undefined reference to `FTExtrudeFont::FTExtrudeFont(char const*)'

Maybe the two of you should get together and try and help each other since you are appear to be trying to solve the same (homework?) problem.