Using homebrew installed SDL2 with Xcode

后端 未结 2 1341
深忆病人
深忆病人 2020-12-31 09:09

I have installed SDL2 using Homebrew but now I don\'t know how to make sure Xcode can use it! I imported the created library and added it to the build phases tab of my proje

2条回答
  •  不思量自难忘°
    2020-12-31 09:14

    1. brew search sdl2

    2. brew install sdl2 sdl2_image sdl2_mixer sdl2_net sdl2_ttf

    3. config xcode Build Settings --> All --> Search Paths --> Header Serch Paths
      --> /usr/local/include

    4. config Xcode General ->add Frameworks and Libraries --> libSDL2-2.0.0.dylib

    5. test your code

    #include 
    #include 
    #include 
    
    using namespace std;
    
    int main() {
    
        if(SDL_Init(SDL_INIT_VIDEO) < 0) {
            cout << "SDL init failed." << endl;
            return 1;
        }
    
        cout << "SDL Init succeeded." << endl;
    
        SDL_Quit();
    
        return 0;
    }
    

提交回复
热议问题