Compiling (?) GLUI on MacOS X

Has anyone succesfully compiled the GLUI Library in MacOS X? I have been trying to make a ProjectBuilder project first to make and then to link the GLui Labrary, to no avail.

I hacked together something that worked a while ago and have been meaning to tidy it up and submit the changes to Paul Rademacher. Try this:

  1. Global search and replace. Change GL/ to GLUT/ (in #includes).

  2. Changes to main() in example1.cpp, example2.cpp, example3.cpp, example4.cpp, and example5.cpp:

    2.1 Add the following as the first line in the body of main():
    glutInit(&argc, argv);

    2.2 Change the return type of main() to int ie. int main(int argc, char* argv[])

    2.3 Add return 0; as the last line in the body of main.

If you are using the command line compiler with a Makefile replace the first few lines in the Makefile with:

CC=c++ -O3
CPPFLAGS=
GLUT_LIB_LOCATION=/System/Library/Frameworks/OpenGL.framework/Libraries
GLLIBS=-L${GLUT_LIB_LOCATION} -lGL -lGLU
LPATH=
INCS=
FRAMEWORKS=-framework GLUT

libs = ${FRAMEWORKS} ${GLLIBS} -lobjc

LIBGLUI= -Llib -lglui

If you are using Project Builder use a Kernal Extension->Library target, and include the GLUT framework. I have a PB project that compiles the lib and all the examples if you want it.

Cheers
Jed

Jed

Thank you very much for the offer. I’ll take you upon it. If it isn’t over 1 Mb, you can send me the PB project to leguinn at hotmail dot com.

Best regards

-Leguinn

Success! I finally got it working!!!

In addition to making Jed’s suggested changes, this is the makefile I whipped. All my old Wintel examples work now flawlessly.

-Leguinn

#This makefile is only for MacOS X

#Glui local subdirectories bin and lib must already exist
#if not, create them with mkdir (or command shift N)

.SUFFIXES: .cpp

CFLAGS =

CC=c++ -O3
CPPFLAGS=
GLUT_LIB_LOCATION=/System/Library/Frameworks/OpenGL.framework/Libraries
GLLIBS=-L${GLUT_LIB_LOCATION} -lGL -lGLU
LPATH=
INCS=
FRAMEWORKS=-framework GLUT

libs = ${FRAMEWORKS} ${GLLIBS} -lobjc

LIBGLUI= -Llib -lglui

All: lib/libglui.a bin/example1 bin/example2 bin/example3 bin/example4 bin/example5

GLUI_OBJS = glui_add_controls.o glui.o glui_bitmap_img_data.o glui_bitmaps.o glui_button.o glui_edittext.o glui_checkbox.o glui_node.o glui_radio.o glui_statictext.o glui_panel.o glui_separator.o glui_spinner.o glui_control.o glui_column.o glui_translation.o glui_rotation.o glui_mouse_iaction.o glui_listbox.o glui_rollout.o arcball.o algebra3.o quaternion.o

bin/example1: $(GLUI_OBJS) example1.o lib/libglui.a
@echo “Linking example1”
$(CC) $(CFLAG) $(CPPFLAGS) $(LPATH) example1.o $(LIBGLUI) $(libs) -o bin/example1

bin/example2: $(GLUI_OBJS) example2.o lib/libglui.a
@echo “Linking example2”
$(CC) $(CFLAG) $(CPPFLAGS) $(LPATH) example2.o $(LIBGLUI) $(libs) -o bin/example2

bin/example3: $(GLUI_OBJS) example3.o lib/libglui.a
@echo “Linking example3”
$(CC) $(CFLAG) $(CPPFLAGS) $(LPATH) example3.o $(LIBGLUI) $(libs) -o bin/example3

bin/example4: $(GLUI_OBJS) example4.o lib/libglui.a
@echo “Linking example4”
$(CC) $(CFLAG) $(CPPFLAGS) $(LPATH) example4.o $(LIBGLUI) $(libs) -o bin/example4

bin/example5: $(GLUI_OBJS) example5.o lib/libglui.a
@echo “Linking example5”
$(CC) $(CFLAG) $(CPPFLAGS) $(LPATH) example5.o $(LIBGLUI) $(libs) -o bin/example5

lib/libglui.a: $(GLUI_OBJS)
@echo “Creating library”
libtool -static -v -o lib/libglui.a $(GLUI_OBJS)

.cpp.o:
$(CC) -c $(CFLAGS) $(CPPFLAGS) $(INCS) $*.cpp

.c.o:
$(CC) -c $(CFLAGS) $(CPPFLAGS) $(INCS) $*.c
clean:
/bin/rm *.o

algebra3.o: algebra3.h
arcball.o: arcball.h algebra3.h quaternion.h stdinc.h
example1.o: glui.h
example2.o: glui.h
example3.o: glui.h
example4.o: glui.h
glui.o: glui.h stdinc.h
glui_add_controls.o: glui.h stdinc.h
glui_bitmap_img_data.o: glui_img_checkbox_0.c glui_img_checkbox_1.c
glui_bitmap_img_data.o: glui_img_radiobutton_0.c glui_img_radiobutton_1.c
glui_bitmap_img_data.o: glui_img_uparrow.c glui_img_downarrow.c
glui_bitmap_img_data.o: glui_img_leftarrow.c glui_img_rightarrow.c
glui_bitmap_img_data.o: glui_img_spinup_1.c glui_img_spinup_0.c
glui_bitmap_img_data.o: glui_img_spindown_1.c glui_img_spindown_0.c
glui_bitmap_img_data.o: glui_img_checkbox_0_dis.c glui_img_checkbox_1_dis.c
glui_bitmap_img_data.o: glui_img_radiobutton_0_dis.c
glui_bitmap_img_data.o: glui_img_radiobutton_1_dis.c glui_img_spinup_dis.c
glui_bitmap_img_data.o: glui_img_spindown_dis.c
glui_bitmaps.o: glui.h stdinc.h
glui_button.o: glui.h stdinc.h
glui_checkbox.o: glui.h stdinc.h
glui_column.o: glui.h stdinc.h
glui_control.o: glui.h stdinc.h
glui_edittext.o: glui.h stdinc.h
glui_node.o: glui.h stdinc.h
glui_panel.o: glui.h stdinc.h
glui_radio.o: glui.h stdinc.h
glui_separator.o: glui.h stdinc.h
glui_spinner.o: glui.h stdinc.h
glui_statictext.o: glui.h stdinc.h
quaternion.o: quaternion.h algebra3.h stdinc.h
glui_translation.o: glui.h stdinc.h
glui_rotation.o: glui.h stdinc.h
glui_mouse_iaction.o: glui.h stdinc.h
glui_listbox.o: glui.h stdinc.h
glui_rollout.o: glui.h stdinc.h


Congratulations Leguinn.

Did you receive the PB files I sent through? Send me an email at jedsoane at mac.com if you didn’t.

Also here’s a nicer way to add the Apple headers so that the same code will compile on other platforms:

#if defined(APPLE_CC)
#include <GLUT/glut.h>
#else
#include <GL/glut.h>
#endif

Jed

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.