Opengl compile error on linux?(undefined reference to `glutInit')

Hey, I’ve got a gentoo(linux distribution) system I am trying to teach myself OpenGL programming with; and when I compile my very basic first step I get:

undefined reference to `glutInit'

my code has an include block like:

#include <stdlib.h>
#include <GL/gl.h>
#include <GL/glu.h>
#include <GL/glut.h>
#include <GL/glx.h>

and my Makefile reads:

CPP = /usr/bin/g++ 
SDLFLAGS = `sdl-config --cflags --libs` 
LIBS = -lGL -lGLU -lXi -lXmu -lglut -lX11
SOURCES = Point.cpp Box.cpp
DEST = boxTest

default:
	${CPP} ${SOURCES} -o ${DEST}

clean:
	rm -f ${DEST}

My main method reads:

int main(int argc,char** argv){
		
		// initialise glutHey, I've got a gentoo system I am trying to teach myself OpenGL programming with; and when I compile my very basic first step I get:

undefined reference to `glutInit’

my code has an include block like: 

#include <stdlib.h>
#include <GL/gl.h>
#include <GL/glu.h>
#include <GL/glut.h>
#include <GL/glx.h>

and my Makefile reads:

CPP = /usr/bin/g++
SDLFLAGS = sdl-config --cflags --libs
LIBS = -lGL -lGLU -lXi -lXmu -lglut -lX11
SOURCES = Point.cpp Box.cpp
DEST = boxTest

default:
${CPP} ${SOURCES} -o ${DEST}

clean:
rm -f ${DEST}

My main method reads:


int main(int argc,char** argv){

	// initialise glut
	glutInit(&argc,argv);
  return 0;

}

I've emerged openglut; so this isn't an issue of Glut not being installed.
		glutInit(&argc,argv);
      return 0;
}

I’ve installed glut; so this isn’t an issue of Glut not being installed.

  1. Did you ensure glut is on your library paths ?
  2. Did you tried to compile it the hard way (g++ … directly on the command line) ?

Try:

LIBS = -L /usr/X11R6/lib -lGL -lGLU -lXi -lXmu -lglut -lX11

Your makefile doesn’t seem to use the LIBS variable when linking your program. The default rule should read something like

default:
	${CPP} -o ${DEST} ${SOURCES} ${LIBS}