SFML community forums
Help => Graphics => Topic started by: lotnik9o on February 23, 2012, 01:35:01 pm
-
I've a problem to linking this code:
int main()
{
// Create the main rendering window
sf::RenderWindow App(sf::VideoMode(800, 600, 32), "SFML Graphics");
// Start game loop
while (App.IsOpened())
{
// Process events
sf::Event Event;
while (App.GetEvent(Event))
{
// Close window : exit
if (Event.Type == sf::Event::Closed)
App.Close();
}
// Clear the screen (fill it with black color)
App.Clear();
// Display window contents on screen
App.Display();
}
return EXIT_SUCCESS;
}
(http://www.sfml-dev.org/tutorials/1.6/graphics-window.php)
and I got this errors:
1>Linking...
1>create_w.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) public: void __thiscall sf::Window::Display(void)" (__imp_?Display@Window@sf@@QAEXXZ)
1>create_w.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) public: bool __thiscall sf::Window::GetEvent(class sf::Event &)" (__imp_?GetEvent@Window@sf@@QAE_NAAVEvent@2@@Z)
1>create_w.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) public: bool __thiscall sf::Window::IsOpened(void)const " (__imp_?IsOpened@Window@sf@@QBE_NXZ)
1>create_w.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) public: void __thiscall sf::Window::Close(void)" (__imp_?Close@Window@sf@@QAEXXZ)
1>create_w.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) public: __thiscall sf::VideoMode::VideoMode(unsigned int,unsigned int,unsigned int)" (__imp_??0VideoMode@sf@@QAE@III@Z)
1>C:\Users\Documents\Visual Studio 2008\Projects\1_create_window\Release\1_create_window.exe : fatal error LNK1120: 5 unresolved externals
1>Build log was saved at "file://c:\Users\Szymon\Documents\Visual Studio 2008\Projects\1_create_window\1_create_window\Release\BuildLog.htm"
Earlier I linking my programs with window.hpp and there were none problems. Can someone help me?
-
You must link (as in "add to the linker settings", not just include the header) to the sfml-window library, the same way you did with sfml-system.
Same with sfml-graphics if you use the graphics module (Graphics.hpp).
-
Thank you for answer. I did so with sfml-graphics, but the problem is still the same, only with the graphics module.
(http://obrazki.elektroda.pl/7635841900_1330002347_thumb.jpg) (http://obrazki.elektroda.pl/7635841900_1330002347.jpg)
I had none problems to linking when I use the system or window module.
-
You still need sfml-window and sfml-system, sfml-graphics doesn't replace them.
-
I got it :) Thank you very much!