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

Author Topic: SFML 2.1 error  (Read 1599 times)

0 Members and 1 Guest are viewing this topic.

Wissam

  • Newbie
  • *
  • Posts: 6
    • View Profile
    • Email
SFML 2.1 error
« on: September 13, 2014, 03:11:50 pm »
Hello, i've been experiencing this frustrating error for hours now, and I can't seem to fix it!

Here's the code (using the sample code from the site)
#include <SFML/Graphics.hpp>

int main()
{
    sf::RenderWindow window(sf::VideoMode(200, 200), "SFML works!");
    sf::CircleShape shape(100.f);
    shape.setFillColor(sf::Color::Green);

    while (window.isOpen())
    {
        sf::Event event;
        while (window.pollEvent(event))
        {
            if (event.type == sf::Event::Closed)
                window.close();
        }

        window.clear();
        window.draw(shape);
        window.display();
    }

    return 0;
}
 

here's the error.

Error   1       error LNK2019: unresolved external symbol "__declspec(dllimport) public: __thiscall sf::String::String(char const *,class std::locale const &)" (__imp_??0String@sf@@QAE@PBDABVlocale@std@@@Z) referenced in function _main     c:\Users\Ricky\documents\visual studio 2012\Projects\sfm-app\sfm-app\main.obj   sfm-app
Error   2       error LNK2019: unresolved external symbol "__declspec(dllimport) public: __thiscall sf::String::~String(void)" (__imp_??1String@sf@@QAE@XZ) referenced in function _main        c:\Users\Ricky\documents\visual studio 2012\Projects\sfm-app\sfm-app\main.obj   sfm-app
Error   3       error LNK2019: unresolved external symbol "__declspec(dllimport) public: __thiscall sf::VideoMode::VideoMode(unsigned int,unsigned int,unsigned int)" (__imp_??0VideoMode@sf@@QAE@III@Z) referenced in function _main   c:\Users\Ricky\documents\visual studio 2012\Projects\sfm-app\sfm-app\main.obj   sfm-app
Error   4       error LNK2019: unresolved external symbol "__declspec(dllimport) public: void __thiscall sf::Window::close(void)" (__imp_?close@Window@sf@@QAEXXZ) referenced in function _main c:\Users\Ricky\documents\visual studio 2012\Projects\sfm-app\sfm-app\main.obj   sfm-app
Error   5       error LNK2019: unresolved external symbol "__declspec(dllimport) public: bool __thiscall sf::Window::isOpen(void)const " (__imp_?isOpen@Window@sf@@QBE_NXZ) referenced in function _main        c:\Users\Ricky\documents\visual studio 2012\Projects\sfm-app\sfm-app\main.obj   sfm-app
Error   6       error LNK2019: unresolved external symbol "__declspec(dllimport) public: bool __thiscall sf::Window::pollEvent(class sf::Event &)" (__imp_?pollEvent@Window@sf@@QAE_NAAVEvent@2@@Z) referenced in function _main        c:\Users\Ricky\documents\visual studio 2012\Projects\sfm-app\sfm-app\main.obj   sfm-app
Error   7       error LNK2019: unresolved external symbol "__declspec(dllimport) public: void __thiscall sf::Window::display(void)" (__imp_?display@Window@sf@@QAEXXZ) referenced in function _main     c:\Users\Ricky\documents\visual studio 2012\Projects\sfm-app\sfm-app\main.obj   sfm-app
Error   8       error LNK1120: 7 unresolved externals   c:\users\ricky\documents\visual studio 2012\Projects\sfm-app\Debug\sfm-app.exe  sfm-app

 

screenshots:





help and suggestions are much appreciated thanks for your time!


note: using sfml 2.1, vs 2012 express

Ixrec

  • Hero Member
  • *****
  • Posts: 1241
    • View Profile
    • Email
Re: SFML 2.1 error
« Reply #1 on: September 13, 2014, 03:16:36 pm »
It looks like you're only linking against sfml-graphics right now.  The graphics module depends on the system and window modules, so you need them too.

Wissam

  • Newbie
  • *
  • Posts: 6
    • View Profile
    • Email
Re: SFML 2.1 error
« Reply #2 on: September 13, 2014, 03:27:57 pm »
wow thanks i really didnt know it was an easy fix how could i be so blind.
i thought that the fact im including the graphics lib then i would only need that.

thanks for clearing it up!

Ixrec

  • Hero Member
  • *****
  • Posts: 1241
    • View Profile
    • Email
Re: SFML 2.1 error
« Reply #3 on: September 13, 2014, 03:32:29 pm »
That is how #includes work during compilation, but for static linking all dependencies need to be explicitly linked against.  You may not have noticed the difference if you've only used the standard libraries before, because the linking is done automagically for them.