This is a pretty noob question. Basically I can't seem to be able to compile a basic Hello World program on OSX (Yosemite) using the SDL2 external library.
I'm trying to do this on console, without the help of any IDEs. I already installed the SDL 2.0.3 and it is located on the /Library/Frameworks/SDL2.framework
path.
My main file looks like this:
#include <SDL2/SDL.h> #include <stdio.h> bool init(); void close(); SDL_Window* gameWindow = NULL; SDL_Surface* gameScreenSurface = NULL; bool init() { ... } void close() { ... } int main( int argc, char** argv) { if( !init() ) { printf( "Failed to initialize!\n" ); } else { SDL_Delay( 2000 ); } close(); return 0; }
And I also have a makefile (taken from an example I found somewhere) that looks like this:
CC = g++ LDFLAGS = -g -Wall PROGNAME = doom SOURCES = main.cpp INCLUDES = OBJECTS = $(subst %.cc, %.o, $(SOURCES)) ROOTCFLAGS := $(shell root-config --cflags) ROOTLIBS := $(shell root-config --libs) ROOTGLIBS := $(shell root-config --glibs) ROOTLIBS := $(shell root-config --nonew --libs) CFLAGS += $(ROOTCFLAGS) LIBS += $(ROOTLIBS) all: doom $(PROGNAME): $(OBJECTS) $(CC) $(LDFLAGS) -o doom $(OBJECTS) $(LIBS) %.o : %.cc $(INCLUDES) $(CC) ${CFLAGS} -c -g -o $@ $<
And that's about it. When I run make
, I receive this response:
make: root-config: Command not found make: root-config: Command not found make: root-config: Command not found make: root-config: Command not found g++ -g -Wall -o doom main.cpp Undefined symbols for architecture x86_64: "_SDL_CreateWindow", referenced from: init() in main-8b6fae.o "_SDL_Delay", referenced from: _main in main-8b6fae.o "_SDL_DestroyWindow", referenced from: close() in main-8b6fae.o "_SDL_GetError", referenced from: init() in main-8b6fae.o "_SDL_GetWindowSurface", referenced from: init() in main-8b6fae.o "_SDL_Init", referenced from: init() in main-8b6fae.o "_SDL_Quit", referenced from: close() in main-8b6fae.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: *** [doom] Error 1
So, can I get some guidance please? I'm a little lost on where to start. I have never compiled a program on OSX or any Unix-based OS before.
I searched for that root-config thing that I'm missing, and It seems that I have to install a library called Root. I did it. Uncompressed it on a directory, don't know where to go from there.
Thanks in advance.