Go Back   The macosxhints Forums > OS X Help Requests > UNIX - General



Reply
 
Thread Tools Rating: Thread Rating: 5 votes, 5.00 average. Display Modes
Old 09-07-2009, 07:22 AM   #1
aneuryzma
Triple-A Player
 
Join Date: May 2007
Posts: 158
error: GL/glut.h: No such file or directory

hi,

I get this error when I compile my source on mac Leopard.

is because I need to configure openGL path ?

Code:
Monitor.h:15:60: error: GL/glut.h: No such file or directory
Monitor.h:16:60: error: GL/gl.h: No such file or directory
Monitor.C: In function 'void display2()':
Monitor.C:77: error: 'glutSetWindow' was not declared in this scope
Monitor.C:78: error: 'GL_COLOR_BUFFER_BIT' was not declared in this scope
Monitor.C:78: error: 'glClear' was not declared in this scope
Monitor.C:87: error: 'glColor3f' was not declared in this scope
Monitor.C:88: error: 'glRasterPos2f' was not declared in this scope
Monitor.C:104: error: 'GLUT_BITMAP_HELVETICA_10' was not declared in this scope
Monitor.C:104: error: 'glutBitmapCharacter' was not declared in this scope
Monitor.C:115: error: 'glutSwapBuffers' was not declared in this scope
Monitor.C: In function 'void display()':
Monitor.C:134: error: 'GL_COLOR_BUFFER_BIT' was not declared in this scope
Monitor.C:134: error: 'glClear' was not declared in this scope
Monitor.C:168: error: 'glColor3f' was not declared in this scope
Monitor.C:169: error: 'glRecti' was not declared in this scope
Monitor.C:195: error: 'glColor3f' was not declared in this scope
Monitor.C:197: error: 'GL_POLYGON' was not declared in this scope
Monitor.C:197: error: 'glBegin' was not declared in this scope
Monitor.C:204: error: 'glVertex2f' was not declared in this scope
Monitor.C:206: error: 'glEnd' was not declared in this scope
Monitor.C:211: error: 'glRasterPos2f' was not declared in this scope
Monitor.C:214: error: 'GLUT_BITMAP_HELVETICA_10' was not declared in this scope
Monitor.C:214: error: 'glutBitmapCharacter' was not declared in this scope
Monitor.C:242: error: 'glColor3f' was not declared in this scope
Monitor.C:244: error: 'GL_POLYGON' was not declared in this scope
Monitor.C:244: error: 'glBegin' was not declared in this scope
Monitor.C:245: error: 'glVertex2f' was not declared in this scope
Monitor.C:248: error: 'glEnd' was not declared in this scope
Monitor.C:253: error: 'glRasterPos2f' was not declared in this scope
Monitor.C:256: error: 'GLUT_BITMAP_HELVETICA_10' was not declared in this scope
Monitor.C:256: error: 'glutBitmapCharacter' was not declared in this scope
Monitor.C:270: error: 'glColor3f' was not declared in this scope
Monitor.C:274: error: 'GL_LINES' was not declared in this scope
Monitor.C:274: error: 'glBegin' was not declared in this scope
Monitor.C:275: error: 'glVertex2d' was not declared in this scope
Monitor.C:277: error: 'glEnd' was not declared in this scope
Monitor.C:282: error: 'GL_LINES' was not declared in this scope
Monitor.C:282: error: 'glBegin' was not declared in this scope
Monitor.C:283: error: 'glVertex2d' was not declared in this scope
Monitor.C:285: error: 'glEnd' was not declared in this scope
Monitor.C:296: error: 'glutSwapBuffers' was not declared in this scope
Monitor.C: In function 'void reshape(int, int)':
Monitor.C:320: error: 'glViewport' was not declared in this scope
Monitor.C:322: error: 'glutSetWindow' was not declared in this scope
Monitor.C:323: error: 'glutReshapeWindow' was not declared in this scope
Monitor.C:324: error: 'glutPositionWindow' was not declared in this scope
Monitor.C: In function 'void reshape2(int, int)':
Monitor.C:336: error: 'glViewport' was not declared in this scope
Monitor.C: In function 'void idle(int)':
Monitor.C:358: error: 'glutSetWindow' was not declared in this scope
Monitor.C:359: error: 'glutPostRedisplay' was not declared in this scope
Monitor.C:364: error: 'glutTimerFunc' was not declared in this scope
Monitor.C: In function 'int main(int, char**)':
Monitor.C:647: error: 'glutInit' was not declared in this scope
Monitor.C:648: error: 'GLUT_DOUBLE' was not declared in this scope
Monitor.C:648: error: 'GLUT_RGB' was not declared in this scope
Monitor.C:648: error: 'glutInitDisplayMode' was not declared in this scope
Monitor.C:649: error: 'glutInitWindowSize' was not declared in this scope
Monitor.C:651: error: 'glutCreateWindow' was not declared in this scope
Monitor.C:653: error: 'GL_PROJECTION' was not declared in this scope
Monitor.C:653: error: 'glMatrixMode' was not declared in this scope
Monitor.C:654: error: 'glLoadIdentity' was not declared in this scope
Monitor.C:655: error: 'GLdouble' was not declared in this scope
Monitor.C:655: error: expected `)' before 'PS'
Monitor.C:656: error: expected `)' before 'PS'
Monitor.C:657: error: 'glOrtho' was not declared in this scope
Monitor.C:658: error: 'GL_MODELVIEW' was not declared in this scope
Monitor.C:661: error: 'glClearColor' was not declared in this scope
Monitor.C:662: error: 'GL_COLOR_BUFFER_BIT' was not declared in this scope
Monitor.C:662: error: 'glClear' was not declared in this scope
Monitor.C:664: error: 'glutTimerFunc' was not declared in this scope
Monitor.C:665: error: 'glutDisplayFunc' was not declared in this scope
Monitor.C:666: error: 'glutReshapeFunc' was not declared in this scope
Monitor.C:668: error: 'glutCreateMenu' was not declared in this scope
Monitor.C:669: error: 'glutAddMenuEntry' was not declared in this scope
Monitor.C:673: error: 'GLUT_LEFT_BUTTON' was not declared in this scope
Monitor.C:673: error: 'glutAttachMenu' was not declared in this scope
Monitor.C:674: error: 'GLUT_RIGHT_BUTTON' was not declared in this scope
Monitor.C:675: error: 'glutKeyboardFunc' was not declared in this scope
Monitor.C:679: error: 'glutCreateSubWindow' was not declared in this scope
Monitor.C:684: error: expected `)' before numeric constant
Monitor.C:684: error: expected `)' before 'PS'
Monitor.C:685: error: expected `)' before numeric constant
Monitor.C:696: error: 'glutMainLoop' was not declared in this scope
make[3]: *** [Monitor.o] Error 1
make[2]: *** [all-recursive] Error 1
make[1]: *** [all] Error 2
make: *** [all-recursive] Error 1

thanks
aneuryzma is offline   Reply With Quote
Old 09-07-2009, 09:38 AM   #2
dmacks
All Star
 
Join Date: Dec 2004
Posts: 678
Yes. The solution to "compiler can't find a header" is always to pass information about where that header is to the compiler (assuming the header actually exists on your system...gotta check that first, which will also tell you where it is). How is entirely dependent on what you're compiling and how its specific makefiles, configure scripts, and other such things are coded.
dmacks is offline   Reply With Quote
Old 09-07-2009, 12:43 PM   #3
aneuryzma
Triple-A Player
 
Join Date: May 2007
Posts: 158
Hi,

I've correct the path to the headers in the source code...
Now I get this error:


Quote:
/bin/sh ../libtool --mode=link g++ -g -O2 -o pursuit_monitor Monitor.o MonitorParameters.o RGBcolor.o ../../pursuitbase/pursuitbase/libConnection.la ../../pursuitbase/pursuitbase/libGenericValues.la -lpthread -lnsl -lglut -lXi -lGLU -lGL
g++ -g -O2 -o pursuit_monitor Monitor.o MonitorParameters.o RGBcolor.o -Wl,-bind_at_load ../../pursuitbase/pursuitbase/.libs/libConnection.a ../../pursuitbase/pursuitbase/.libs/libGenericValues.a -lpthread -lnsl -lglut -lXi -lGLU -lGL

ld: library not found for -lnsl

is a library missing ?

thanks

Last edited by aneuryzma; 09-07-2009 at 12:58 PM.
aneuryzma is offline   Reply With Quote
Old 09-07-2009, 01:25 PM   #4
dmacks
All Star
 
Join Date: Dec 2004
Posts: 678
libnsl is the "name services library" on linux (and maybe some other unix flavors). I think the functions are part of libSystem, which is automatically linked by default (no need for a -l flag). You could try removing that flag and seeing if linking succeeds. If it fails, it will probably tell you the exact symbols it was wanting from libnsl, and you can look for where they are defined on OS X.
dmacks is offline   Reply With Quote
Old 09-07-2009, 02:05 PM   #5
aneuryzma
Triple-A Player
 
Join Date: May 2007
Posts: 158
hi,

if I remove "-lnsl" then I have the same problem with "-lglut".

ld: library not found for -lglut.

I tried to use ./configure again after changing the source (I forgot before) and now I get this error:

Quote:
checking for glMatrixMode in -lGL... no
configure: error: Could not find the GL library.

what should I do ?

thanks
aneuryzma is offline   Reply With Quote
Old 09-07-2009, 03:04 PM   #6
nijm
Triple-A Player
 
Join Date: Jul 2006
Posts: 85
Some years ago I needed to write some GL stuff using GLUT, for linux and OS X both. The key to getting everything working on the mac (without resorting to fink/X11) was to add the -framework argument to the linker stage. Here is a tiny makefile that compiled it successfully on OS X.

Code:
LIBPATH += -L"/System/Library/Frameworks/OpenGL.framework/Libraries"

FRAMEWORK = -framework GLUT
FRAMEWORK += -framework OpenGL 

COMPILERFLAGS = -Wall
CC = gcc
CFLAGS = $(COMPILERFLAGS) 
LIBRARIES = -lGL -lGLU -lobjc -lstdc++ -lfftw3 -lm
SOURCES = fslice.h globals.h manip.c GLUTcallbacks.c main.c
OBJECTS = main.o 
All: main
$(OBJECTS):$(SOURCES)
main: main.o $(OBJECTS) 
	$(CC) $(FRAMEWORK) $(CFLAGS) -o $@ $(LIBPATH) $(OBJECTS) $(LIBRARIES)

	./main
nijm is offline   Reply With Quote
Old 09-07-2009, 03:19 PM   #7
aneuryzma
Triple-A Player
 
Join Date: May 2007
Posts: 158
hi!

thanks for the tip, but how can I merge this makefile you provided with the existent one ?


ps. I've uploaded my makefile if it can help
Attached Files
File Type: txt Makefile.txt (15.5 KB, 173 views)

Last edited by aneuryzma; 09-07-2009 at 04:17 PM.
aneuryzma is offline   Reply With Quote
Old 09-08-2009, 05:12 PM   #8
nijm
Triple-A Player
 
Join Date: Jul 2006
Posts: 85
When you compile (or the linker stage really), you have to have the arguments:

Code:
-L"/System/Library/Frameworks/OpenGL.framework/Libraries" -framework GLUT -framework OpenGL -lGL -lGLU
But I see you used automake. Did you run automake on your mac, or did you just try and bring it all over from linux in one go? You probably need to run automake and ./configure on the mac. Even then, I don't know if it will work out of the box. Probably not.

Oh, I forgot one other thing: when you include, if you used <GL/glut.h> before, change this to <GLUT/glut.h>. If you are including <gl.h> and/or <glu.h>, change them to <OpenGL/gl.h> and/or <OpenGL/glu.h>. They are not in the same directories on OS X as they are on other flavours of unix.

I once brought over a project from linux to mac and reran 'automake and friends' as they call it. It worked out and compiled just fine, but I was using X11 and not any native GUI stuff. I suspect automake doesn't know about frameworks, you may have to go with X11. This means getting the full stack of tools for GL and X11 from fink or macports. But once you do, you may be able to rerun automake etc, then compile with no problem.
nijm is offline   Reply With Quote
Reply

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump



All times are GMT -5. The time now is 09:29 PM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.
Site design © IDG Consumer & SMB; individuals retain copyright of their postings
but consent to the possible use of their material in other areas of IDG Consumer & SMB.