PDA

View Full Version : glutDisplayFunc problem



sanosuke001
09-15-2005, 04:24 AM
I am getting this error when I try to compile my program. Note: the program compiled a few months ago and I haven't changed it since. I do not know why. I am on a solaris machine.

"settingScene.C", line 288: Warning (Anachronism): Formal argument func of type extern "C" void(*)() in call to glutDisplayFunc(extern "C" void(*)()) is being passed void(*)().
1 Warning(s) detected.
CC -o settingScene settingScene.o
Undefined first referenced
symbol in file
glShadeModel settingScene.o
sunOglCurrentContext settingScene.o
glBegin settingScene.o
glutInit settingScene.o
glMatrixMode settingScene.o
glutDisplayFunc settingScene.o
glLightfv settingScene.o
glClearDepth settingScene.o
glMaterialfv settingScene.o
glDepthFunc settingScene.o
glutInitDisplayMode settingScene.o
glColorMaterial settingScene.o
glEnd settingScene.o
glutInitWindowSize settingScene.o
glClear settingScene.o
glEnable settingScene.o
glMaterialf settingScene.o
glClearColor settingScene.o
glLoadIdentity settingScene.o
gluPerspective settingScene.o
glHint settingScene.o
glutCreateWindow settingScene.o
sunOglCurPrimTablePtr settingScene.o
glutMainLoop settingScene.o
glutSwapBuffers settingScene.o
gluLookAt settingScene.o
ld: fatal: Symbol referencing errors. No output written to settingScene
*** Error code 1
make: Fatal error: Command failed for target `settingScene'

memfr0b
09-15-2005, 05:14 AM
The first warning seems to be caused by using a C++ compiler and not declaring your display function as extern "C".

The linker errors result from not linking against glut/GLU/GL. Add a "-lglut -lGLU -lGL" (and if necessary -L<path-to-gl-libs>) to your linker call.

sanosuke001
09-15-2005, 05:24 AM
I think I do. This is the header.mak file I use:

#
# This header.mak file will set up all necessary options for compiling
# and linking C and C++ programs which use OpenGL and/or GLUT.
#
# To use the GNU C or C++ compiler, add one of the following lines:
#
# CC = gcc
CCC = g++
#
OWINC=/usr/openwin/include
OWLIB=/usr/openwin/lib
GLUTINC=/usr/local/glut/include
GLUTLIB=/usr/local/glut/lib/glut

LDLIBS = -lglut -lGLU -lGLw -lGL -lGLw -lXmu -lXext -lX11 -lm

INCLUDE = -I$(GLUTINC) -I$(OWINC)
LIBDIRS = -L$(GLUTLIB) -L$(OWLIB)

CCFLAGS = -g $(INCLUDE)
CFLAGS = -g $(INCLUDE)

LIBFLAGS = -g $(LIBDIRS) $(LDLIBS)

It used to work, but now it doesnt. Also, the part about the extern C, I saw someone when I was looking for an answer said that happens in solaris and to not worry about it. Don't know if it's true or not, but it didn't happen before.

Stephen

memfr0b
09-15-2005, 07:06 AM
Well, LDLIBS/LIBFLAGS certainly has the right content, but it doesn't seem to be used when linking your binary.

If you are using pre-defined rules for compilation, you should use the variable LDFLAGS instead of LIBFLAGS. If not, make sure you actually have LIBFLAGS in your linker call.