Hi
I installed SFML 2.5.1 in VS2017, and i have a problem. I wrote a test code:
#include <SFML/Graphics.hpp>
#include <cmath>
int main()
{
sf::RenderWindow okno(sf::VideoMode(320, 240), "Kurs SFML 2.0 - http://cpp0x.pl");
sf::Clock stoper;
while (okno.isOpen())
{
sf::Event event;
while (okno.pollEvent(event))
{
if (event.type == sf::Event::Closed)
okno.close();
} //while
okno.clear();
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);
okno.draw(ksztalt);
okno.display();
} //while
return 0;
}
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)
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?
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:
sfml-network-d.lib
sfml-graphics-d.lib
sfml-window-d.lib
sfml-system-d.lib
sfml-audio-d.lib
vorbis.lib
vorbisenc.lib
vorbisfile.lib
openal32.lib
ogg.lib
freetype.lib
flac.lib
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
Here is errored code:
int checkServerStat(void)
{
std::cout << "Connecting to the server...\n";
sf::TcpSocket socket;
if (socket.connect(serverIp, serverPort) == sf::Socket::Done)
{
std::cout << "Server OK\n";
return 0;
socket.close(); //<- Error
}
else
{
std::cout << "Cannot connect to the server\n";
return 1;
}
}