SFML community forums

Help => General => Topic started by: Tommex on August 19, 2018, 02:43:41 pm

Title: SFML C++ Linker Errors | Visual studio 2017
Post by: Tommex on August 19, 2018, 02:43:41 pm
Hey guys, it's my first time posting here something basically because of an issue that i'm getting on building my project.

I installed SFML 2 days ago and followed a video of how to setup it. now, when i'm trying to build the next code:

#include <SFML/Graphics.hpp>

int main()
{
   sf::RenderWindow window(sf::VideoMode(200, 200), "SFML works!");
   sf::CircleShape shape(100.f);
   shape.setFillColor(sf::Color::Green);

   while (window.isOpen())
   {
      sf::Event event;
      while (window.pollEvent(event))
      {
         if (event.type == sf::Event::Closed)
            window.close();
      }

      window.clear();
      window.draw(shape);
      window.display();
   }

   return 0;
}

I'm keeping getting an Linker Error LNK2019 and LNK1120.
Here is the build error:

Severity   Code   Description   Project   File   Line   Suppression State
Error   LNK2001   unresolved external symbol "public: static class sf::RenderStates const sf::RenderStates::Default" (?Default@RenderStates@sf@@2V12@B)   SFML_TEST   C:\Users\User\source\repos\SFML_TEST\SFML_TEST\Main.obj   1   

Severity   Code   Description   Project   File   Line   Suppression State
Error   LNK2001   unresolved external symbol "public: static class sf::Color const sf::Color::Green" (?Green@Color@sf@@2V12@B)   SFML_TEST   C:\Users\User\source\repos\SFML_TEST\SFML_TEST\Main.obj   1   

Severity   Code   Description   Project   File   Line   Suppression State
Error   LNK1120   2 unresolved externals   SFML_TEST   C:\Users\User\source\repos\SFML_TEST\x64\Debug\SFML_TEST.exe   1   



Here are my properties to the project, hope it helped finding my problem:

https://imgur.com/a/cIHgOZL




Title: Re: SFML C++ Linker Errors | Visual studio 2017
Post by: eXpl0it3r on August 19, 2018, 02:59:12 pm
Why did you define SFML_STATIC? ;)
Title: Re: SFML C++ Linker Errors | Visual studio 2017
Post by: Tommex on August 19, 2018, 03:08:09 pm
I just followed the instructions.
Well, i removed it and now i can build it. but now it shows me another errors about my .lib i think :\

https://imgur.com/a/M5VQhmJ
Title: Re: SFML C++ Linker Errors | Visual studio 2017
Post by: eXpl0it3r on August 19, 2018, 03:43:04 pm
No, the instructions tell you something else. Please read them carefully and don't just look at the images. ;)
Title: Re: SFML C++ Linker Errors | Visual studio 2017
Post by: Tommex on August 19, 2018, 04:05:05 pm
I did everything okay, still getting the error about the dll, what should i do with it?
https://imgur.com/a/M5VQhmJ
Title: Re: SFML C++ Linker Errors | Visual studio 2017
Post by: eXpl0it3r on August 19, 2018, 04:30:03 pm
It's mentioned in the tutorial:

Quote
don't forget to copy the SFML DLLs (they are in <sfml-install-path/bin>) to the directory where your compiled executable is
Title: Re: SFML C++ Linker Errors | Visual studio 2017
Post by: Tommex on August 19, 2018, 05:30:51 pm
Perfecto!! ;D
Problem was solved.
Thank you very much, i hope you helped here not only to my, but for more people that had this issue.  ;)

https://imgur.com/a/OHYsJy0