Search code examples
c++xcodesdl

SDL not compiling with project in Xcode


I am trying to use SDL in Xcode. I included the necessary header files. However, I keep getting error messages at compilation that look like this: Undefined symbol: _AudioObjectAddPropertyListener. I keep getting 100 of these error messages. My code to test SDL looks like this: if (SDL_Init(SDL_INIT_VIDEO)) {cout << "SDL init failed \n";return 1;} else {cout << "SDL Init succeeded \n";SDL_Quit();return 0;} I'm not sure if I included the libraries in the correct way. I tried googling "undefined symbol error Xcode SDL" and none of the results helped me solve my problem. I have a screenshot of the error messages below.

Xcode error messages


Solution

  • Steps:

    1. Open project configuration
    2. Go to build settings tab
    3. Add library search paths
    4. In other linker flags add -L/usr/local/lib -lSDL2 -lm
    5. Try to compile again