Jump to content

  • Log In with Google      Sign In   
  • Create Account


Linux development


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
6 replies to this topic

#1 GameGeazer   Members   -  Reputation: 727

Like
0Likes
Like

Posted 18 October 2012 - 06:27 PM

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.

Sponsor:

#2 Álvaro   Crossbones+   -  Reputation: 11719

Like
2Likes
Like

Posted 18 October 2012 - 07:27 PM

Your header files (/usr/include/...) seem to be fine, but you are not linking the library correctly. Can you extract the exact command line that is doing the linking? It might be printed just above the error messages...

#3 Bregma   Crossbones+   -  Reputation: 4741

Like
1Likes
Like

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.

Edited by Bregma, 18 October 2012 - 07:28 PM.

Stephen M. Webb
Professional Free Software Developer

#4 Bacterius   Crossbones+   -  Reputation: 7990

Like
2Likes
Like

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.

The slowsort algorithm is a perfect illustration of the multiply and surrender paradigm, which is perhaps the single most important paradigm in the development of reluctant algorithms. The basic multiply and surrender strategy consists in replacing the problem at hand by two or more subproblems, each slightly simpler than the original, and continue multiplying subproblems and subsubproblems recursively in this fashion as long as possible. At some point the subproblems will all become so simple that their solution can no longer be postponed, and we will have to surrender. Experience shows that, in most cases, by the time this point is reached the total work will be substantially higher than what could have been wasted by a more direct approach.

 

- Pessimal Algorithms and Simplexity Analysis


#5 Álvaro   Crossbones+   -  Reputation: 11719

Like
1Likes
Like

Posted 18 October 2012 - 07:40 PM

The line
LIBS = -lglut
should probably be
LIBS = -lglut -lGLU

Give that a try.

#6 Bregma   Crossbones+   -  Reputation: 4741

Like
7Likes
Like

Posted 18 October 2012 - 08:28 PM

The line

LIBS = -lglut
should probably be
LIBS = -lglut -lGLU

Give that a try.

Linking libGLU will not be sufficient. You have to link -lGL to pick up the OpenGL library.

LIBS = -lglut -lGLU -lGL
Stephen M. Webb
Professional Free Software Developer

#7 GameGeazer   Members   -  Reputation: 727

Like
0Likes
Like

Posted 19 October 2012 - 06:52 AM

Tyvm for the quick replies guys, that was the problem!




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS