PDA

View Full Version : problem for running a open gl example on mac


skd_aitpune
February 22nd, 2009, 11:30 AM
Hi,

I am using mac to compile and run a graphics example. I had the trouble with the glut libraries but then I downloaded and installed them. The application compiles without errors but fails when I try to execute it giving error

dyld: Library not loaded: /usr/X11/lib/libglut.3.dylib
Referenced from: /Users/sandeep/Documents/graphics/./cube
Reason: image not found
Trace/BPT trap

The make file I am using is

INCLUDE = /Developer/SDKs/MacOSX10.5.sdk/usr/X11/include
LIBDIR = -L/Developer/SDKs/MacOSX10.5.sdk/usr/X11/lib

CC = gcc
CCFLAGS =

OBJFILES = cube.o

LDLIBS = -lX11 -lXi -lXmu -lglut -lGL -lGLU -lm

cube : $(OBJFILES)
$(CC) $(CCFLAGS) -o $@ $(LIBDIR) $(OBJFILES) $(LDLIBS)

cube.o : cube.c
$(CC) $(CCFLAGS) -c cube.c -I$(INCLUDE)

I have been trying out different options through google but nothing helps. If anyone can help me on this. Thanks in advance.

macbri
February 22nd, 2009, 08:20 PM
If you're running this on the command line try setting your DYLD_LIBRARY_PATH env variable:

export DYLD_LIBRARY_PATH=/Developer/SDKs/MacOSX10.5.sdk/usr/X11/lib

Then try running the app again....

skd_aitpune
February 22nd, 2009, 08:41 PM
I tried that now the error message is:

dyld: Library not loaded: /usr/X11/lib/libglut.3.dylib
Referenced from: /Users/sandeep/Documents/graphics/./cube
Reason: no suitable image not found Did find:
/Developer/SDKs/MacOSX10.5.sdk/usr/X11/lib/libglut.3.dylib: can't map
Trace/BPT trap

macbri
February 23rd, 2009, 05:05 PM
Where did you download the libglut files from? And if you do a:

file -L /Developer/SDKs/MacOSX10.5.sdk/usr/X11/lib/libglut.3.dylib

what does it tell you?

skd_aitpune
February 23rd, 2009, 05:52 PM
I downloaded the glut from opengl.org but the libglut.3.dylib was already there.
On running the command said by you what I get is:

/Developer/SDKs/MacOSX10.5.sdk/usr/X11/lib/libglut.3.dylib: Mach-O universal binary with 4 architectures
/Developer/SDKs/MacOSX10.5.sdk/usr/X11/lib/libglut.3.dylib (for architecture ppc7400): Mach-O dynamically linked shared library stub ppc
/Developer/SDKs/MacOSX10.5.sdk/usr/X11/lib/libglut.3.dylib (for architecture i386): Mach-O dynamically linked shared library stub i386
/Developer/SDKs/MacOSX10.5.sdk/usr/X11/lib/libglut.3.dylib (for architecture ppc64): Mach-O 64-bit dynamically linked shared library stub ppc64
/Developer/SDKs/MacOSX10.5.sdk/usr/X11/lib/libglut.3.dylib (for architecture x86_64): Mach-O 64-bit dynamically linked shared library stub x86_64

Anyways I managed to overcome the problem by other way, by using the framework for glut provided in mac for xcode.
Thanks a lot for the help

psv
March 17th, 2009, 08:32 PM
Hi, I have the identical problem. Can you please tell me how you were able to resolve it?

When I run the command
file -L /Developer/SDKs/MacOSX10.5.sdk/usr/X11/lib/libglut.3.dylib

I get the output:

/Developer/SDKs/MacOSX10.5.sdk/usr/X11/lib/libglut.3.dylib: Mach-O universal binary with 4 architectures
/Developer/SDKs/MacOSX10.5.sdk/usr/X11/lib/libglut.3.dylib (for architecture ppc7400): Mach-O dynamically linked shared library stub ppc
/Developer/SDKs/MacOSX10.5.sdk/usr/X11/lib/libglut.3.dylib (for architecture i386): Mach-O dynamically linked shared library stub i386
/Developer/SDKs/MacOSX10.5.sdk/usr/X11/lib/libglut.3.dylib (for architecture ppc64): Mach-O 64-bit dynamically linked shared library stub ppc64
/Developer/SDKs/MacOSX10.5.sdk/usr/X11/lib/libglut.3.dylib (for architecture x86_64): Mach-O 64-bit dynamically linked shared library stub x86_64


Any help will be much appreciated!

skd_aitpune
March 17th, 2009, 10:51 PM
Hi,

I tried to do it many possible ways but the result was u cannot do with the gl and glut libraries on mac.
The dylib libraries gives you linking error, I tired to link it in many ways, static and dynamic but all was fail

What u can do instead is , in you cpp file change all includes from GL to GLUT and the make file would be like this :

CC =g++ -framework Cocoa-framework OpenGL -framework GLUT

u dont need to include any other liraries and all

this worked for me, hope u get ur problem resolved too