1

So, I have problem, when try to use any of static members of SFML Library like sf::RenderState::Default or sf::Color::Blue.

error LNK2001: unresolved external symbol "public: static class sf::RenderStates const sf::RenderStates::Default" (?Default@RenderStates@sf@@2V12@B)

But when I comment lines, I have access to sf::window (it be created, but can't draw anything, because sf::Drawble has sf::RenderState::Default as standart argument).

I checked everything including linker and compiler in Solution properties in Visual Studio (I have VS19).

P.S. I use the latest version of SFML (2.5.1) and Visual C++20.

Thanks for your help.

2
  • Can this help? stackoverflow.com/questions/27594261/… Commented Feb 26, 2021 at 12:15
  • Sorry, It isn't helped and I have already checked this before. Commented Feb 26, 2021 at 12:16

2 Answers 2

1

The troubleshooting steps I would undertake in this situation go from easiest to the inverse of that.

  1. If I check the declaration of sf::RenderState::Default, can it be found?
  2. If I create a new project with just this feature used, does the error persist?
  3. If I redo my linking and directory searches, is the problem fixed?
  4. Do I have a version compatible with my compiler?

Furthermore, the amount of information you've given about your environment is not enough to speculate on what the issue could be. It might be helpful to post your version of SFML, your compiler (and kind), what your project is like (shorthand.)

SFML can be compiled from source if necessary. Sometimes, using an incompatible version on accident will not show any issues on many basic things until you run into weird errors.

See this document on compiling SFML from source: https://www.sfml-dev.org/tutorials/2.5/compile-with-cmake.php

Sign up to request clarification or add additional context in comments.

1 Comment

In this project I haven't this problem before, but several days ago a got this. It can't be found, because of definition is in .hpp file in class, but the current value is placed in binary file. I'm not using CMake, I use solution files, because of this is easier (especially for VS). There is practically no code: I'm creating sf::RectangleShape and just try to draw it. But thanks, I'll try to create new project and test this code again (may be new with CMake).
0

So, thanks for AlixianaBritmonkey, I managed with this problem. I just create new project and moved every file. I don't know why problem occured before, but my solution helped.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.