SFML community forums

Help => General => Topic started by: kamik1979 on October 03, 2020, 11:59:22 am

Title: (Solved) Linker error: sf::Color
Post by: kamik1979 on October 03, 2020, 11:59:22 am
Hi

I installed SFML 2.5.1 in VS2017, and i have a problem. I wrote a test code:

(click to show/hide)

And I got such errors: LNK2001 about sf::Color::Yellow and sf::RenderState::Default.

I imported all the libraries from the SFML-2.5.1\lib folder. I'm doing something wrong? Or this code (I copied it from internet  ;) ) is for older SFML version? I have no idea...

(Sorry for all English language errors, I'm not good at it)
Title: Re: Linker error: sf::Color
Post by: Stauricus on October 03, 2020, 02:38:47 pm
the code has no compile errors, altough you are creating a new circle every frame. just move this
sf::CircleShape ksztalt(std::sin(stoper.getElapsedTime().asSeconds()) * okno.getSize().y / 8 + okno.getSize().y / 4);
      ksztalt.setOrigin(sf::Vector2f(ksztalt.getRadius(), ksztalt.getRadius()));
      ksztalt.setPosition(okno.getSize().x / 2.0f, okno.getSize().y / 2.0f);
      ksztalt.setFillColor(sf::Color::Yellow);
to before this:
while (okno.isOpen())
 

so you won't create a new circle every loop.


but thats probably not what is causing your error. your description does not help much yet. what SO are you using, what version of SFML did you download, and what IDE do you use?
Title: Re: Linker error: sf::Color
Post by: kamik1979 on October 03, 2020, 03:27:52 pm
I'm using Visual Studio Community 2017 in Windows 10 x64 and I downloaded SFML 2.5.1 64 Bit. I'm compiling program with x64 architecture. In Project properties -> Linker -> Input -> Additional dependiences in x64 and Debug I have these entries:

(click to show/hide)

They are all libs that I have in SFML-2.5.1\lib

And in C/C++ -> General -> Additional include directories I have my SFML include folder path. (Similarly for Linker -> General -> Additional library directories I have my SFML lib folder path)

All DLLs are in the project folder.

I can't paste error messages that exactly I have becouse they are in polish language. They are LNK2001 errors. I tested network module and it's not working properly too.

I want to use SFML becouse I want to use network i my C++ program. I know that SFML it's easy way to do that. If you know any easy way to communicate between two computers using internet, I'll be happy if you want to share it with me.

I'm using this tutorial: https://www.youtube.com/watch?v=_9yem5dJt2E&t
Title: Re: Linker error: sf::Color
Post by: eXpl0it3r on October 03, 2020, 04:13:59 pm
You probably defined SFML_STATIC but are trying to link SFML dynamically.
Don't define SFML_STATIC if you link SFML dynamically.
Title: Re: Linker error: sf::Color
Post by: kamik1979 on October 03, 2020, 05:07:31 pm
Oh, yes, I removed SFML_STATIC and some errors vanishes  :P. But still error (another, E0265 and C2248) occurs when I try use TcpSocket::close(). VS 2017 says that it's inaccessible. What do you think about it?
Title: Re: Linker error: sf::Color
Post by: eXpl0it3r on October 03, 2020, 05:47:58 pm
I don't see that in your posted code, so no idea, maybe you're just doing something wrong.
Title: Re: Linker error: sf::Color
Post by: kamik1979 on October 03, 2020, 05:58:13 pm
Here is errored code:

(click to show/hide)
Title: Re: Linker error: sf::Color
Post by: eXpl0it3r on October 03, 2020, 06:02:45 pm
Why are you trying to call close on a socket, after you've returned from the function?

And what's the error exactly?
Title: Re: Linker error: sf::Color
Post by: kamik1979 on October 03, 2020, 06:24:15 pm
No i don't want to close socket after return  ;D. I wanted to show that function only. I can't paste whole error becouse it is in Polish language. Error codes I wrote above, it is E0265 and C2248.
Title: Re: Linker error: sf::Color
Post by: kamik1979 on October 05, 2020, 04:44:23 pm
I have read documentation carefully and i found that TcpSocket::close() is protected. I can close socket using TcpSocket::disconnect(). Thanks for all your help.