- Create new project folder.
- Inside of the project folder, create folders
include
andlib
. - Create main.cpp with code:
#include "include/SFML/Graphics.hpp"
#include "include/box2d/box2d.h"
int main(){}
Notice that since we have headers in the project folder /include, we need to use double quotes "" instead of <>.
- Create
compile.sh
script with the following contents:
#! /bin/sh
g++ -std=c++11 main.cpp -o main -I include -L lib -l sfml-system -l sfml-window -l sfml-graphics -l sfml-audio -l sfml-network -l box2d -Wl,-rpath ./lib
Run this script after you placed sfml and box2d headers and library files into your project. It should compile and run without errors.
- Download Mac version of SFML.
- Copy contents of the include folder and paste them in your projects include folder (it should be project/include/SFML).
- Copy contents of the lib folder (dylib files) and paste them in your projects lib folder.
- Download source code from Github: https://github.com/erincatto/box2d
- Run box2d/build.sh
- From box2d/build/bin folder there is now
libbox2d.a
. Copy and paste it to your projects lib folder. - Copy box2d/include/box2d folder and paste it to your projects include folder.