Using homebrew installed SDL2 with Xcode

本秂侑毒 提交于 2019-11-29 01:54:38

To be able to use SDL2 on Xcode you must set two things (which are required for SDL in general):

  • where to find header files (so that Clang can compile with -Iheader/path)
  • where to find the .dylib to link it to the project (since with brew you don't have a real .framework)

To know the correct paths you should invoke sdl2-config --cflags and sdl2-config --libs. On my system these produce:

:~jack$ /usr/local/bin/sdl2-config --cflags
-I/usr/local/include/SDL2 -I/usr/X11R6/include -D_THREAD_SAFE

:~jack$ /usr/local/bin/sdl2-config --libs
-L/usr/local/lib -lSDL2

Now just paste the first one into other C flags and the other one into other linker flags field of your project and you are ready to go.

You could set them up in the correct fields, which is Header Search Paths for -I and Library Search Path for -l but the result will be the same.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!