Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: SFML C++ Linker Errors | Visual studio 2017  (Read 4801 times)

0 Members and 3 Guests are viewing this topic.

Tommex

  • Newbie
  • *
  • Posts: 4
    • View Profile
    • Email
SFML C++ Linker Errors | Visual studio 2017
« 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




« Last Edit: August 19, 2018, 05:31:02 pm by Tommex »

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11030
    • View Profile
    • development blog
    • Email
Re: SFML C++ Linker Errors | Visual studio 2017
« Reply #1 on: August 19, 2018, 02:59:12 pm »
Why did you define SFML_STATIC? ;)
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

Tommex

  • Newbie
  • *
  • Posts: 4
    • View Profile
    • Email
Re: SFML C++ Linker Errors | Visual studio 2017
« Reply #2 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

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11030
    • View Profile
    • development blog
    • Email
Re: SFML C++ Linker Errors | Visual studio 2017
« Reply #3 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. ;)
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

Tommex

  • Newbie
  • *
  • Posts: 4
    • View Profile
    • Email
Re: SFML C++ Linker Errors | Visual studio 2017
« Reply #4 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

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11030
    • View Profile
    • development blog
    • Email
Re: SFML C++ Linker Errors | Visual studio 2017
« Reply #5 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
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

Tommex

  • Newbie
  • *
  • Posts: 4
    • View Profile
    • Email
Re: SFML C++ Linker Errors | Visual studio 2017
« Reply #6 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

 

anything