SFML community forums
Help => General => Topic started by: lotnik9o on February 20, 2012, 08:18:56 pm
-
I have to make the SFML headers and library files available to Visual C++ 2008 and after bulid:
#include <SFML/System.hpp>
#include <iostream>
int main()
{
sf::Clock Clock;
while (Clock.GetElapsedTime() < 5.f)
{
std::cout << Clock.GetElapsedTime() << std::endl;
sf::Sleep(0.5f);
}
return 0;
}
It gives me the following errors:
1>------ Build started: Project: sf_test, Configuration: Release Win32 ------
1>Linking...
1>testx.obj : error LNK2001: unresolved external symbol "void __cdecl sf::Sleep(float)" (?Sleep@sf@@YAXM@Z)
1>testx.obj : error LNK2001: unresolved external symbol "public: float __thiscall sf::Clock::GetElapsedTime(void)const " (?GetElapsedTime@Clock@sf@@QBEMXZ)
1>testx.obj : error LNK2001: unresolved external symbol "public: __thiscall sf::Clock::Clock(void)" (??0Clock@sf@@QAE@XZ)
1>C:\Users\Szymon\Documents\Visual Studio 2008\Projects\sf_test\Release\sf_test.exe : fatal error LNK1120: 3 unresolved externals
1>Build log was saved at "file://c:\Users\Szymon\Documents\Visual Studio 2008\Projects\sf_test\sf_test\Release\BuildLog.htm"
1>sf_test - 4 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
Can someone help me how to solve this problem?
-
You must link to sfml-system. Please read the tutorial before posting ;)
-
Just a warning that this sample code doesn't work with SFML2.
I believe it's because Clock.GetElapsedTime() now returns an sf::Time object instead, not a float.
Some other sample code to try for SFML2 users:
#include <SFML/System.hpp>
#include <iostream>
int main()
{
sf::Clock clock;
//while (Clock.GetElapsedTime() < 5.f)
//{
//std::cout << Clock.GetElapsedTime() << std::endl;
// sf::Sleep(0.5f);
//}
sf::Time time1 = clock.GetElapsedTime();
std::cout << time1.AsSeconds() << std::endl;
return 0;
}