Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Problem with linking graphics.hpp  (Read 1748 times)

0 Members and 1 Guest are viewing this topic.

lotnik9o

  • Newbie
  • *
  • Posts: 6
    • View Profile
Problem with linking graphics.hpp
« on: February 23, 2012, 01:35:01 pm »
I've a problem to linking this code:
Code: [Select]
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:
Code: [Select]
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?

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Problem with linking graphics.hpp
« Reply #1 on: February 23, 2012, 01:44:59 pm »
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).
Laurent Gomila - SFML developer

lotnik9o

  • Newbie
  • *
  • Posts: 6
    • View Profile
Problem with linking graphics.hpp
« Reply #2 on: February 23, 2012, 02:06:23 pm »
Thank you for answer. I did so with sfml-graphics, but the problem is still the same, only with the graphics module.



I had none problems to linking when I use the system or window module.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Problem with linking graphics.hpp
« Reply #3 on: February 23, 2012, 02:22:02 pm »
You still need sfml-window and sfml-system, sfml-graphics doesn't replace them.
Laurent Gomila - SFML developer

lotnik9o

  • Newbie
  • *
  • Posts: 6
    • View Profile
Problem with linking graphics.hpp
« Reply #4 on: February 23, 2012, 02:41:37 pm »
I got it :) Thank you very much!