3

Is there a reasonably easy to follow way to link SFML libraries with VSCode in macOS?

My case:

  • Using Mac
  • Using Clang with VSCode
  • Have Xcode installed
  • Am an amateur

Note : I am using clang and Mac

Ashwin Rohit
  • 27
  • 1
  • 4
  • Possible duplicate of [How do i link the SFML libraries in Visual Studio Code?](https://stackoverflow.com/questions/38404670/how-do-i-link-the-sfml-libraries-in-visual-studio-code) – Diogo Rocha Mar 28 '19 at 20:23

4 Answers4

1

See my question and answer here: Manually link and compile C++ program with SFML (macOS)

In a nutshell:

  • download sfml for mac
  • copy include directory from extracted folder to your project directory
  • copy the dynamic library files to your project also, folder lib
  • in terminal type the g++ command and link to the dynamic libs

It will be something like this:

g++ main.cpp -o main -I include -L lib -l sfml-system -l sfml-window -l sfml-graphics -l sfml-audio -l sfml-network -Wl,-rpath ./lib
Mulperi
  • 1,450
  • 1
  • 14
  • 24
0

here's a boiler plate to link sfml in vs code:

https://github.com/andrew-r-king/sfml-vscode-boilerplate

grybouilli
  • 185
  • 2
  • 11
0

If you have Macbook M1, the other answers won't work. The reason is because sfml from the website is compiled in x86_64, and you can't compile the libraries directly to arm64. So, you need sfml and pkg-config to be installed on Homebrew.

Command:

g++ main.cpp $(pkg-config --libs --cflags sfml-window sfml-system sfml-graphics) -o main

More detailed solution here: https://stackoverflow.com/a/53510642/16264548

If you don't wan to use pkg-config, then you can manually type in the locations:

main.cpp -I/opt/homebrew/Cellar/sfml/2.5.1_1/include -L/opt/homebrew/Cellar/sfml/2.5.1_1/lib -lsfml-window -lsfml-system -lsfml-graphics -o main
0

To enable the editor features, you can add library include files to C/C++ configurations:

  • Open Command Palette (⇧⌘P by default)
  • Type and select "C/C++: Edit Configurations (UI)"
  • In section "Include path" add a line: /your/path/to/sfml/include/*

In my case, the path is /usr/local/Cellar/sfml/2.5.1_1/include/*