Ian H
Ian H

Reputation: 105

C++/OpenGL - Starting a new project

I'm starting a new project using C++ and OpenGL to make a simple game and to teach myself OpenGL. I do not want to use GLUT, and would rather use SDL for making windows and such. I'm having a lot of weird trouble with the Makefile, however. Currently, when I type make, I get this response when I include $(LFLAGS) $(LDFLAGS) in my G++ commands:

g++-5 tetris.o -o tetris -std=c++14
Undefined symbols for architecture x86_64:
  "_SDL_CreateWindow", referenced from:
      _main in tetris.o
  "_SDL_GL_CreateContext", referenced from:
      _main in tetris.o
  "_SDL_Init", referenced from:
      _main in tetris.o
  "_SDL_PollEvent", referenced from:
      game_loop(SDL_Window*)     in tetris.o
  "_glewGetErrorString", referenced from:
      _main in tetris.o
  "_glewInit", referenced from:
      _main in tetris.o
ld: symbol(s) not found for architecture x86_64
collect2: error: ld returned 1 exit status
make: *** [tetris] Error 1

and this response when I do not:

g++-5 -Wall  -framework SDL2 tetris.o -o tetris -std=c++14
ld: framework not found SDL2
collect2: error: ld returned 1 exit status
make: *** [tetris] Error 1

Here is my new Makefile:

CC = g++-5
CFLAGS = -Wall -c -Wno-deprecated-declarations
LFLAGS = -Wall 
LDFLAGS = -framework SDL2
LDLIBS= -lSDL2 -lglew -lGL
INCLUDES = -I/Library/Frameworks/SDL2.framework/Headers/
STD = -std=c++14

all: tetris

tetris: tetris.o
    $(CC) $(LFLAGS) $(LDFLAGS) tetris.o -o tetris $(STD)

tetris.o: tetris.cpp
    $(CC) $(CFLAGS) $(LDFLAGS) -o $@ tetris.cpp $(STD)

.PHONY: clean

clean: 
    rm tetris *.o

And the headers part of my .cpp file:

#include <SDL2/SDL.h>
#include <GL/glew.h>
#include <unistd.h>
#include <iostream>

Upvotes: 4

Views: 358

Answers (2)

Patrice Chaula
Patrice Chaula

Reputation: 9

Just use freeglut, you don't need to use SDL so that you can get started with OpenGL.

Upvotes: 0

sav_a
sav_a

Reputation: 121

maybe you need to add

LDFLAGS = -framework GLUT 

to your Makefile

Upvotes: 3

Related Questions