Which dylib in OpenGL framework gets linked? (simple glut ex)
This is my first post here, and I'm also just getting started with OSX and Obj-C. :)
I made a small glut example program by:
-- using PB to create a Cocoa app,
-- added the GLUT and OpenGL frameworks to the project,
-- renamed main.m to main.c, wiped out what was in there:
and put in this:
and after a 'clean', it built and ran fine.
(Hmm.. Is that the correct way to set up a program using glut?)
My question is, exactly which library am I linking to?
Looking in /System/Library/Frameworks/OpenGL.framework, there's a Mach-O dylib named OpenGL, but also in a Libraries subdirectory, there's libGL.dylib and libGLU.dylib.
How can I tell which library (libGL.dylib or OpenGL) I'm linking to? (No ldd command here. :) )
Why is the file OpenGL named without the .dylib extension?
I made a small glut example program by:
-- using PB to create a Cocoa app,
-- added the GLUT and OpenGL frameworks to the project,
-- renamed main.m to main.c, wiped out what was in there:
Code:
#import <Cocoa/Cocoa.h>
int main(int argc, const char *argv[])
{
return NSApplicationMain(argc, argv);
}and put in this:
Code:
#include <OpenGL/gl.h>
#include <OpenGL/glu.h>
#include <GLUT/glut.h>
void initGL();
void drawGLScene();
void resizeGLScene( int width, int height );
int main(int argc, char *argv[])
{
glutInit( &argc, argv );
glutInitDisplayMode( GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH );
glutInitWindowSize( 400, 600 );
glutInitWindowPosition( 100, 200 );
glutCreateWindow( argv[0] );
initGL();
glutDisplayFunc( drawGLScene );
glutReshapeFunc( resizeGLScene );
glutMainLoop();
return 0;
}
void initGL()
{
glShadeModel( GL_SMOOTH );
glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
glClearDepth(1.0f);
glEnable( GL_DEPTH_TEST );
glDepthFunc( GL_EQUAL );
glHint( GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST );
}
void drawGLScene()
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glLoadIdentity();
}
void resizeGLScene( int width, int height )
{
if ( height == 0 ) height = 1;
if ( width == 0 ) width = 1;
glViewport( 0, 0, width, height );
glMatrixMode( GL_PROJECTION );
glLoadIdentity();
gluPerspective(
45.0,
(float)width / (float)height,
1.0,
10.0 );
glMatrixMode( GL_MODELVIEW );
glLoadIdentity();
}and after a 'clean', it built and ran fine.
(Hmm.. Is that the correct way to set up a program using glut?)
My question is, exactly which library am I linking to?
Looking in /System/Library/Frameworks/OpenGL.framework, there's a Mach-O dylib named OpenGL, but also in a Libraries subdirectory, there's libGL.dylib and libGLU.dylib.
How can I tell which library (libGL.dylib or OpenGL) I'm linking to? (No ldd command here. :) )
Why is the file OpenGL named without the .dylib extension?
Read up on the manpage for otool - it'll tell you what libraries you're using.
Did you ever wonder why we had to run for shelter when the promise of a brave new world unfurled beneath the clear blue sky?
Thanks Steven. Looks like the most common use of otool for app devs is otool -L executable which is very similar to ldd.
You're linking to the framework, not the individual dylibs. I suspect (though I don't know) that the framework links to the dylibs, but the OpenGL framework is unusual in even having any dylibs.
> but the OpenGL framework is unusual in even having any dylibs.
Ahh,.. I hadn't noticed that. I see that there's only four that contain dylibs:
ApplicationServices.framework
CoreServices.framework
JavaVM.framework
OpenGL.framework
Ahh,.. I hadn't noticed that. I see that there's only four that contain dylibs:
ApplicationServices.framework
CoreServices.framework
JavaVM.framework
OpenGL.framework
Ah. Ok. The OpenGL Mach-O has a bunch of CGL stuff in it. (Hmm. Interesting and possibly relevant article: http://developer.apple.com/qa/qa2001/qa1269.html )
whereas, ''otool -vT Libraries/libGL.dylib" shows me all the OpenGL functions that I expect to see (a long list including glVertex3*(), etc.).
Also, the OpenGL Mach-O relies on libGL.dylib:
Code:
[john /System/Library/Frameworks/OpenGL.framework/Versions/A]$ otool -vT OpenGL
OpenGL:
Table of contents (29 entries)
module name symbol name
cgl_format.o _CGLChoosePixelFormat
cgl_drawable.o _CGLClearDrawable
cgl_context.o _CGLCopyContext
cgl_context.o _CGLCreateContext
cgl_format.o _CGLDescribePixelFormat
cgl_renderer.o _CGLDescribeRenderer
cgl_context.o _CGLDestroyContext
cgl_format.o _CGLDestroyPixelFormat
cgl_renderer.o _CGLDestroyRendererInfo
cgl_state.o _CGLDisable
cgl_state.o _CGLEnable
cgl_error.o _CGLErrorString
cgl_swap.o _CGLFlushDrawable
cgl_context.o _CGLGetNextContext
cgl_drawable.o _CGLGetOffScreen
cgl_option.o _CGLGetOption
cgl_state.o _CGLGetParameter
cgl_drawable.o _CGLGetSurface
cgl_version.o _CGLGetVersion
cgl_context.o _CGLGetVirtualScreen
cgl_state.o _CGLIsEnabled
cgl_renderer.o _CGLQueryRendererInfo
cgl_drawable.o _CGLSetFullScreen
cgl_drawable.o _CGLSetOffScreen
cgl_option.o _CGLSetOption
cgl_state.o _CGLSetParameter
cgl_drawable.o _CGLSetSurface
cgl_context.o _CGLSetVirtualScreen
cgl_drawable.o _CGLUpdateContextwhereas, ''otool -vT Libraries/libGL.dylib" shows me all the OpenGL functions that I expect to see (a long list including glVertex3*(), etc.).
Also, the OpenGL Mach-O relies on libGL.dylib:
Code:
[john /System/Library/Frameworks/OpenGL.framework/Versions/A]$ otool -L OpenGL
OpenGL:
/System/Library/Frameworks/OpenGL.framework/Versions/A/OpenGL
(compatibility version 1.0.0, current version 1.0.0)
/System/Library/Frameworks/ApplicationServices.framework/Versions/A/ApplicationServices
(compatibility version 1.0.0, current version 18.0.0)
/System/Library/Frameworks/IOKit.framework/Versions/A/IOKit
(compatibility version 1.0.0, current version 120.4.0)
/System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation
(compatibility version 150.0.0, current version 263.5.0)
/System/Library/Frameworks/OpenGL.framework/Versions/A/Libraries/libGLU.dylib
(compatibility version 1.0.0, current version 1.0.0)
/System/Library/Frameworks/OpenGL.framework/Versions/A/Libraries/libGL.dylib
(compatibility version 1.0.0, current version 1.0.0)
/usr/lib/libSystem.B.dylib
(compatibility version 1.0.0, current version 63.0.0)
[john /System/Library/Frameworks/OpenGL.framework/Versions/A]$ otool -L Libraries/libGL.dylib
Libraries/libGL.dylib:
/System/Library/Frameworks/OpenGL.framework/Versions/A/Libraries/libGL.dylib
(compatibility version 1.0.0, current version 1.0.0)
/usr/lib/libSystem.B.dylib
(compatibility version 1.0.0, current version 63.0.0)
Possibly Related Threads...
| Thread: | Author | Replies: | Views: | Last Post | |
| Simple OpenGL ES problem | soulstorm | 3 | 3,390 |
May 14, 2009 03:53 PM Last Post: AnotherJake |
|
| Simple OpenGL 2d test - nothing displaying | SaxMan | 8 | 5,469 |
Jan 19, 2009 12:04 AM Last Post: TythosEternal |
|
| OpenGL ES - Drawing a simple cube help. | MattCairns | 7 | 11,126 |
Oct 10, 2008 05:26 PM Last Post: Frogblast |
|
| OpenGL and GLUT on MacOSX | Salvietta | 1 | 2,051 |
Sep 19, 2008 12:03 PM Last Post: OneSadCookie |
|
| Dealing with GLUT and OpenGL... | RingoEST | 10 | 4,969 |
Aug 16, 2008 12:24 AM Last Post: RingoEST |
|

