I just got started on OpenGL programming. Started with super bible 5 to begin with.

Following their example in chapter 2 on triangle, I was able to get it working fine on Xcode.

I was trying to however get this working on a Terminal in mac - that way I do not have to use Xcode.

So I did the following:

1. My makefile

CHAPTER = Chapter2
MAIN = Triangle
SRCPATH = ~/Scratch/OpenGL/SB5/$(CHAPTER)/$(MAIN)/
GLTSRCPATH = ~/Scratch/OpenGL/SB5/Src/GLTools/src/
GLTINCPATH = ~/Scratch/OpenGL/SB5/Src/GLTools/include/
LIBS = GLTools
INCDIRS = -I $(GLTINCPATH) -I $(GLTINCPATH)GL
LIBDIRS = -L/Users/alm/Scratch/OpenGL/SB5/XCode/GLTools/

CC = gcc
FMWK = -framework GLUT -framework OpenGL

prog : $(MAIN)

$(MAIN).o : $(SRCPATH)$(MAIN).cpp
$(CC) -c $(INCDIRS) $(MAIN).cpp

$(MAIN) : $(MAIN).o
$(CC) $(FMWK) $(LIBDIRS) -l$(LIBS) $(MAIN).o -o $(MAIN)

clean :
rm -rf *.o $(MAIN)


2. Triangle code (straight from the text)
I am also using the libGLTools.a that is provided in the Xcode directory


3. Result of compilation
- Triangle compiles fines other than for warnings
gcc -c -I ~/Scratch/OpenGL/SB5/Src/GLTools/include/ -I ~/Scratch/OpenGL/SB5/Src/GLTools/include/GL Triangle.cpp
In file included from Triangle.cpp:9:
/Users/alm/Scratch/OpenGL/SB5/Src/GLTools/include/GLTools.h:76:1: warning: "glGenVertexArrays" redefined
In file included from /Users/alm/Scratch/OpenGL/SB5/Src/GLTools/include/GLTools.h:62,
from Triangle.cpp:9:
/Users/alm/Scratch/OpenGL/SB5/Src/GLTools/include/GL/glew.h:4797:1: warning: this is the location of the previous definition
In file included from Triangle.cpp:9:
/Users/alm/Scratch/OpenGL/SB5/Src/GLTools/include/GLTools.h:77:1: warning: "glDeleteVertexArrays" redefined
In file included from /Users/alm/Scratch/OpenGL/SB5/Src/GLTools/include/GLTools.h:62,
from Triangle.cpp:9:
/Users/alm/Scratch/OpenGL/SB5/Src/GLTools/include/GL/glew.h:4796:1: warning: this is the location of the previous definition
In file included from Triangle.cpp:9:
/Users/alm/Scratch/OpenGL/SB5/Src/GLTools/include/GLTools.h:78:1: warning: "glBindVertexArray" redefined
In file included from /Users/alm/Scratch/OpenGL/SB5/Src/GLTools/include/GLTools.h:62,
from Triangle.cpp:9:
/Users/alm/Scratch/OpenGL/SB5/Src/GLTools/include/GL/glew.h:4795:1: warning: this is the location of the previous definition
In file included from Triangle.cpp:9:
/Users/alm/Scratch/OpenGL/SB5/Src/GLTools/include/GLTools.h:80:1: warning: "glGenerateMipmap" redefined
In file included from /Users/alm/Scratch/OpenGL/SB5/Src/GLTools/include/GLTools.h:62,
from Triangle.cpp:9:
/Users/alm/Scratch/OpenGL/SB5/Src/GLTools/include/GL/glew.h:3238:1: warning: this is the location of the previous definition
gcc -framework GLUT -framework OpenGL -L/Users/alm/Scratch/OpenGL/SB5/XCode/GLTools/ -lGLTools Triangle.o -o Triangle

- Problem is when I link to using their GLTools library
gcc -framework GLUT -framework OpenGL -L/Users/alm/Scratch/OpenGL/SB5/XCode/GLTools/ -lGLTools Triangle.o -o Triangle
Undefined symbols:
"operator delete[](void*)", referenced from:
GLBatch::~GLBatch()in libGLTools.a(GLBatch.o)
GLBatch::~GLBatch()in libGLTools.a(GLBatch.o)
GLBatch::~GLBatch()in libGLTools.a(GLBatch.o)
GLBatch::~GLBatch()in libGLTools.a(GLBatch.o)
.....
.....
"operator delete(void*)", referenced from:
GLBatch::~GLBatch()in libGLTools.a(GLBatch.o)
GLTriangleBatch::~GLTriangleBatch()in libGLTools.a(GLTriangleBatch.o)
"vtable for __cxxabiv1::__class_type_info", referenced from:
typeinfo for GLBatchBasein libGLTools.a(GLBatch.o)
typeinfo for GLBatchBasein libGLTools.a(GLTriangleBatch.o)
"operator new[](unsigned long)", referenced from:
GLBatch::Begin(unsigned int, unsigned int, unsigned int)in libGLTools.a(GLBatch.o)
GLBatch::Begin(unsigned int, unsigned int, unsigned int)in libGLTools.a(GLBatch.o)

...
...

"___cxa_pure_virtual", referenced from:
....
.....
"vtable for __cxxabiv1::__si_class_type_info", referenced from:
...
"___gxx_personality_v0", referenced from:
....
....

Was wondering how to resolve these undefined symbols (7 of them)?

I tried compiling the GLTools instead of using what they provided but get the same result (errors)