I downloaded SDL2-2.0.3
. I ran ./configure && make && make install
.
I've also tried brew install SDL2
.
This is my main.c
//Using SDL and standard IO
#include <SDL2/SDL.h>
#include <stdio.h>
//Screen dimension constants
const int SCREEN_WIDTH = 640;
const int SCREEN_HEIGHT = 480;
int main( int argc, char* args[] ) {
SDL_Window* window = NULL;
SDL_Surface* screenSurface = NULL;
if (SDL_Init( SDL_INIT_VIDEO ) < 0 ) {
printf( "SDL could not initialize! SDL_Error: %s\n", SDL_GetError() );
}
}
When I run it
~:.make main
gcc main.c -o main
Undefined symbols for architecture x86_64:
"_SDL_GetError", referenced from:
_main in main-d5699d.o
"_SDL_Init", referenced from:
_main in main-d5699d.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: *** [main] Error 1
~:.
How do I install this?
You are failing to link with libSDL2.{a,dylib}
.
You want:
gcc -o main main.c -lSDL2
or perhaps:
gcc -o main main.c -L/usr/local/lib -lSDL2