Hi,
I used glut and sdl2 before and now i tried to make something completely on my own with openGL, sdl2 and glew. I wrote my own makefile now and i think it works, but i always get this error when i try to compile it:
g++ -c -Wall -I/usr/local/include main.cpp
g++ -c -Wall -I/usr/local/include Display.cpp
g++ -L/usr/local/lib -lSDL2 -lGLEW -o booom main.o Display.o
Undefined symbols for architecture x86_64:
"_glClear", referenced from:
Display::Clear(float, float, float, float) in Display.o
"_glClearColor", referenced from:
Display::Clear(float, float, float, float) in Display.o
"_glCullFace", referenced from:
Display::Display(int, int, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) in Display.o
"_glEnable", referenced from:
Display::Display(int, int, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) in Display.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [all] Error 1
I have only my main.cpp and my Display class. This small program should only create a window for me.
I try to compile it on osx, version 10.9.5.
glew version: 1.12.0 (compiled on my own, also tried it with the homebrew version. changes nothing)
sdl2 version: 2.0.3
Here is my makefile:
#my compiler
CC=g++
#my program name
PRGNAME=booom
#library search directory
LIBDIR=-L/usr/local/lib
#library names
#uses libSDL2.a, libGLEW.a
LIBNAME=-lSDL2 -lGLEW
#includes for libraries
INCLUDES=-I/usr/local/include
#my compiler options
CFLAGS=-c -Wall
all: main.o Display.o
$(CC) $(LIBDIR) $(LIBNAME) -o $(PRGNAME) main.o Display.o
#main.cpp is the dependency of main.o
main.o: main.cpp
$(CC) $(CFLAGS) $(INCLUDES) main.cpp
Display.o: Display.cpp
$(CC) $(CFLAGS) $(INCLUDES) Display.cpp
clean:
rm -rf *o booom
i searched a lot on google,but i haven’t found a fix that works for me. also most people on osx use xcode, but i don’t want to use xcode anymore because its osx only.