1

I wanted to compile some of my C++ SFML games that I wrote on Linux so my friends can play it but I don't know how to compile my projects in Visual Studio.

After I add sfml2.5.1/include path to "Additional include directories", SFML_STATIC to "Preprocessor definitions", sfml 2.5.1/lib directory to "Additional library directories" and sfml-graphics.lib;sfml-window.lib;sfml-system.lib to "Additional dependencies" and then run it, it says:

fatal error LNK1181: cannot open input file 'sfml-graphics.lib'

I tried to change sfml*.lib to libsfml*.a and here is first 3 lines of 52 of what it saying:

1>Game.obj : error LNK2001: unresolved external symbol "public: static class sf::RenderStates const sf::RenderStates::Default" (?Default@RenderStates@sf@@2V12@B)
1>Game.obj : error LNK2001: unresolved external symbol "public: static class sf::Color const sf::Color::White" (?White@Color@sf@@2V12@B)
1>Game.obj : error LNK2001: unresolved external symbol "public: virtual class sf::Vector2<float> __cdecl sf::CircleShape::getPoint(unsigned __int64)const " (?getPoint@CircleShape@sf@@UEBA?AV?$Vector2@M@2@_K@Z)

What to do with this?

Adrian Mole
  • 49,934
  • 160
  • 51
  • 83
Vitalii
  • 19
  • 6
  • Add the path to `sfml-graphics.lib` to the linker search path. https://stackoverflow.com/questions/10847076/how-do-i-add-a-lib-file-to-link-in-visual-c-2010/10847128#10847128 – harper Oct 15 '22 at 16:49

1 Answers1

0

I recently had to do a similar thing and I found vcpkg very easy and convenient. I did:

> git clone https://github.com/Microsoft/vcpkg.git
> .\vcpkg\bootstrap-vcpkg.bat -disableMetrics
> .\vcpkg\vcpkg integrate install
> .\vcpkg\vcpkg install sfml:x64-windows

Then, in the Visual Studio project, just include the library headers:

#include <SFML/Graphics.hpp>

Then it should compile and link, creating a dll for the library in your build folder.

MatG
  • 574
  • 2
  • 7
  • 19