Skip to content
/ sfml-macos Public template

How to build and run a SFML program in VSCode on MacOS

Notifications You must be signed in to change notification settings

Beatzoid/sfml-macos

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SFML C++ MacOS Example

A very simple example of how to use SFML in VSCode on MacOS

Prerequisites

  1. Git
  2. VSCode
  3. Homebrew
  4. Make

Setup

First, clone this repo

git clone https://github.com/beatzoid/sfml-macos

Or you can click the green Use this template to automagically make a new repo under your account with all the files (example) and then clone that.


Then, open it in VSCode,

install SFML using homebrew

brew install sfml

and get the path to the installation

brew info sfml

You will see something like /opt/homebrew/Cellar/sfml/2.5.1_2 in the output. If the numbers differ it's ok. First, you need to edit the Makefile and change the SFML_PATH variable to the path you got above. Then, open .vscode/c_cpp_properties.json and change the second entry in the includePath array to the path you got.

Then, press Cmd+Shift+B in VSCode to build and FN+F5 to run. If it works, you should see a window with a black background and cyan circle. Once you exit the program, you should also see the number "5" in the terminal. Congrats, you can now make whatever you want with SFML!

Credit

This StackOverflow answer