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

Author Topic: SFML not working  (Read 1596 times)

0 Members and 1 Guest are viewing this topic.

veselina

  • Guest
SFML not working
« on: October 25, 2022, 08:52:08 am »
I am trying to learn SFML but it keeps giving me two error messages:
Error   LNK2001 unresolved external symbol "public: static class sf::RenderStates const sf::RenderStates::Default" (?Default@RenderStates@sf@@2V12@B)   SFML_HELLO_WORLD        C:\Users\brayd\Documents\Coding\Application_Projects\SFML_HELLO_WORLD\SFML_HELLO_WORLD\SFML_HELLO_WORLD.obj     1      
 
and
Error   LNK2001 unresolved external symbol "public: static class sf::Color const sf::Color::Blue" (?Blue@Color@sf@@2V12@B)      SFML_HELLO_WORLD        C:\Users\brayd\Documents\Coding\Application_Projects\SFML_HELLO_WORLD\SFML_HELLO_WORLD\SFML_HELLO_WORLD.obj     1      
 
here is my code:
#include <SFML/Graphics.hpp>
#include <iostream>

// SFML installation
// Make sure SFML is 32-bit version
// Go to Project > (Name) Properties > C/C++ > Additional Include Directories.
// Add C:\SFML-#.#.#
// Go to Linker and add SFML\lib to Additional Include Libraries
// Go to Linker > Input and add the required .lib files (sfml-graphics.lib, sfml-window.lib, sfml-system.lib, etc.)
// Go to C/C++ > Preprocessor > Preprocessor Definitions and add SFML_STATIC
// Add all files from SFML\bin to project folder

int main()
{
        sf::RenderWindow window(sf::VideoMode(800, 600), "Hello World");
        sf::CircleShape shape(100.f);
        shape.setFillColor(sf::Color::Blue);

        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;
        }
}
 

euscar

  • Newbie
  • *
  • Posts: 17
    • View Profile
Re: SFML not working
« Reply #1 on: October 25, 2022, 04:03:16 pm »
I have tried your code with Orwell Dev-C ++ and it works fine.

Which IDE are you using?
Did you set the dependencies correctly?

P.S. the "return 0" statement must be placed after the penultimate closing curly brace (}).

Jim Marsden

  • Newbie
  • *
  • Posts: 3
    • View Profile
    • Email
Re: SFML not working
« Reply #2 on: November 11, 2022, 08:51:07 pm »
Greetings, at the risk of being rude, did you link sfml-graphics to your project?

Did you follow the getting started section of https://www.sfml-dev.org/tutorials/2.5/

 

anything