When I'm compiling a simple example with SDL 2.0, after the command SDL_CreateWindow, this occurring the following error: "Passed a NULL mutex".
I'm using the static library project. Also I'm testing on OSX 10.8.3.
This inform missing something on the command line compilation?
Below is the command line to generate the program generation and code example.
Compiler:
clang++ -I "TestSDL/sdl/include" -Wall -c -x c++ -arch x86_64 -std=c++11 -stdlib=libc++ -MMD -MP -MF"src/main.d" -MT"src/main.d" -o "src/main.o" "../src/main.cpp"
Linker:
clang++ -L "TestSDL/sdl/lib" -arch x86_64 -stdlib=libc++ -Bstatic -framework GLUT -framework ForceFeedBack -framework IOKit -framework CoreAudio -framework CoreFoundation -framework Carbon -framework AudioUnit -framework AudioToolbox -framework OpenGL -framework Cocoa -o "TestSDL" ./src/main.o -lSDL2
Code:
#include "SDL.h"
#include <iostream>
using namespace std;
void checkSDLError(int line = -1)
{
const char *error = SDL_GetError();
if (*error != '\0') {
cout << "SDL Error: " << error << " line: " << line << endl;
SDL_ClearError();
}
}
int main(int argc, char **argv)
{
if (SDL_Init(SDL_INIT_EVERYTHING) < 0) {
return false;
}
SDL_Window * window = SDL_CreateWindow("Test SDL", SDL_WINDOWPOS_CENTERED,
SDL_WINDOWPOS_CENTERED, 512, 512,
SDL_WINDOW_SHOWN);
checkSDLError(__LINE__);
if (!window) {
cout << "Unable to create window" << endl;
return 1;
}
SDL_Event event;
while (true) {
while (SDL_PollEvent(&event)) {
switch (event.type) {
case SDL_QUIT:
return 1;
default:
break;
}
}
}
SDL_DestroyWindow(window);
SDL_Quit();
}