I'm trying to set up a development environment on linux but I've run into an error where my ide recognizes the libraries and event goes to finish my line when I type in "glGenTextures," but throws a bunch of errors like these:
/home/william/programming/workspaces/cplusplus/Test2/main.cpp|49|error: undefined reference to 'glGenTextures'|
/home/william/programming/workspaces/cplusplus/Test2/main.cpp|50|error: undefined reference to 'glBindTexture'|
/home/william/programming/workspaces/cplusplus/Test2/main.cpp|58|error: undefined reference to 'glTexImage2D'|
/home/william/programming/workspaces/cplusplus/Test2/main.cpp|63|error: undefined reference to 'glEnable'|
/home/william/programming/workspaces/cplusplus/Test2/main.cpp|64|error: undefined reference to 'glEnable'|
I set up Opengl using this guy's tutorial(which was very comprehensive, I don't see anywhere I could have missed a step)
http://www.videotutorialsrock.com/opengl_tutorial/get_opengl_setup_linux/video.php
my usr/include/GL contains all the files show in the video.
I've tried compiling this in Code: blocks and with this guy's make file.
I assume its a problem with linking, but I'm having trouble resolve exactly what to do.
Linux development
Started by GameGeazer, Oct 18 2012 06:27 PM
6 replies to this topic
Ad:
#3 Members - Reputation: 2761
Posted 18 October 2012 - 07:27 PM
You have added the header search path so the preprocessor can find the OpenGL header files.
You also have to add the OpenGL shared libraries for the linker to resolve those symbols. I don't know how to do it in your IDE, but it's gping to be something like "-lGL" added to the linker command line. This will pick up the library /usr/lib/libGL.so, which is probably a symbolic link to the real OpenGL library (for example, /usr/lib/x86_64-linux-gnu/mesa/libGL.so.1.2.0 on my system).
Look around for the linker settings and try adding that.
You also have to add the OpenGL shared libraries for the linker to resolve those symbols. I don't know how to do it in your IDE, but it's gping to be something like "-lGL" added to the linker command line. This will pick up the library /usr/lib/libGL.so, which is probably a symbolic link to the real OpenGL library (for example, /usr/lib/x86_64-linux-gnu/mesa/libGL.so.1.2.0 on my system).
Look around for the linker settings and try adding that.
Edited by Bregma, 18 October 2012 - 07:28 PM.
Stephen M. Webb
Professional Free Software Developer
Professional Free Software Developer
#4 Crossbones+ - Reputation: 3517
Posted 18 October 2012 - 07:34 PM
This is the makefile in question:
[source lang="plain"]CC = g++CFLAGS = -WallPROG = cubeSRCS = main.cpp imageloader.cppifeq ($(shell uname),Darwin) LIBS = -framework OpenGL -framework GLUTelse LIBS = -lglutendifall: $(PROG)$(PROG): $(SRCS) $(CC) $(CFLAGS) -o $(PROG) $(SRCS) $(LIBS)clean: rm -f $(PROG)[/source]
As you can see, he is not linking to OpenGL but only to GLUT. He must've added them somewhere else, or perhaps he is going through the first branch. Try adding -lGL (note that's a lower-case L, not an i) after -lglut and see what happens.
[source lang="plain"]CC = g++CFLAGS = -WallPROG = cubeSRCS = main.cpp imageloader.cppifeq ($(shell uname),Darwin) LIBS = -framework OpenGL -framework GLUTelse LIBS = -lglutendifall: $(PROG)$(PROG): $(SRCS) $(CC) $(CFLAGS) -o $(PROG) $(SRCS) $(LIBS)clean: rm -f $(PROG)[/source]
As you can see, he is not linking to OpenGL but only to GLUT. He must've added them somewhere else, or perhaps he is going through the first branch. Try adding -lGL (note that's a lower-case L, not an i) after -lglut and see what happens.
#6 Members - Reputation: 2761
Posted 18 October 2012 - 08:28 PM
Linking libGLU will not be sufficient. You have to link -lGL to pick up the OpenGL library.The line
LIBS = -lglutshould probably beLIBS = -lglut -lGLU
Give that a try.
LIBS = -lglut -lGLU -lGL
Stephen M. Webb
Professional Free Software Developer
Professional Free Software Developer






