Linking SDL2 emits countless linking errors on OSX

Viewed 1428

I have this super simple SDL2 executable:

#include <SDL.h>

int main(void)
{
    SDL_Texture* t;
    SDL_DestroyTexture(t);
}

I try to compile it like this:

clang++ $(sdl2-config --cflags --libs) foo.cc 

This grants me with a barrage of Linking errors, which all have to do with Objective-C and Apple Libraries. I can do the same with SDL_Surface* s; SDL_DestroySurface(s); and it won't emit these errors.

I have found out that I can solve this problem by using $(sdl2-config --static-libs). But I'm pretty sure, I shouldn't need to use this. After all shouldn't the SDL2 library already be linked to them? Why is it only appearing with SDL_Texture, but not with SDL_Surface? What am I doing wrong?

EDIT: I don't know why I got the downvote. Here I have a small sample of the linking errors:

Undefined symbols for architecture x86_64:
  "_AudioObjectAddPropertyListener", referenced from:
      _COREAUDIO_Init in libSDL2.a(SDL_coreaudio.o)
      _COREAUDIO_OpenDevice in libSDL2.a(SDL_coreaudio.o)
  "_AudioObjectGetPropertyData", referenced from:
      _COREAUDIO_OpenDevice in libSDL2.a(SDL_coreaudio.o)
      _device_unplugged in libSDL2.a(SDL_coreaudio.o)
      _build_device_list in libSDL2.a(SDL_coreaudio.o)
  "_AudioObjectGetPropertyDataSize", referenced from:
  (...)
1 Answers
Related