How do you include files in C++ from the /Library/Framework folder in MAC

前端 未结 2 627
面向向阳花
面向向阳花 2020-12-14 21:44

I am trying to use SDL. I have a folder in /Library/Frameworks called SDL2.framework. I want to include the file SDL.h in my project.

2条回答
  •  鱼传尺愫
    2020-12-14 22:14

    Your header files is under the Headers folder, so in order to include this properly:

    clang++ -std=c++11 -stdlib=libc++ -I/Library/Frameworks/SDL2.framework/Headers/
    

    But I recommend Installing with homebrew:

    brew install sdl2
    

    Homebrew will install SDL2 libSDL2.a file under /usr/local/lib and /usr/local/include, so you will just need to include this Library path using the -L for library and -I flag to add search in /usr/local/include dir:

    clang++ -std=c++11 -stdlib=libc++ main.cpp -I/usr/local/include -L/usr/local/lib -lSDL2 -o programfile
    

    And include:

    #include 
    

提交回复
热议问题