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

Author Topic: I'm Getting Error LNK2019 When Compiling sf::Window  (Read 5797 times)

0 Members and 1 Guest are viewing this topic.

Xela203

  • Newbie
  • *
  • Posts: 1
    • View Profile
I'm Getting Error LNK2019 When Compiling sf::Window
« on: July 06, 2013, 01:44:11 am »
So I am trying to follow the online tutorials off of the SFML website, but I have come across some code that won't compile due to error code LNK2019: unresolved external symbol. Thinking I was just coding wrong, I copied and pasted the example from the website and used it instead, only to get the same result.

#include <SFML/Window.hpp>

int main()
{
    sf::Window window(sf::VideoMode(800, 600), "My window");

    // run the program as long as the window is open
    while (window.isOpen())
    {
        // check all the window's events that were triggered since the last iteration of the loop
        sf::Event event;
        while (window.pollEvent(event))
        {
            // "close requested" event: we close the window
            if (event.type == sf::Event::Closed)
                window.close();
        }
    }

    return 0;
}

Error Code:
Error   1   error LNK2019: unresolved external symbol "public: __thiscall sf::String::String(char const *,class std::locale const &)" (??0String@sf@@QAE@PBDABVlocale@std@@@Z) referenced in function _main   

Error   2   error LNK2019: unresolved external symbol "class sf::Time __cdecl sf::seconds(float)" (?seconds@sf@@YA?AVTime@1@M@Z) referenced in function "public: void __thiscall sf::Window::setFramerateLimit(unsigned int)" (?setFramerateLimit@Window@sf@@QAEXI@Z)   

Error   3   error LNK2019: unresolved external symbol "bool __cdecl sf::operator!=(class sf::Time,class sf::Time)" (??9sf@@YA_NVTime@0@0@Z) referenced in function "public: void __thiscall sf::Window::display(void)" (?display@Window@sf@@QAEXXZ)   

Error   4   error LNK2019: unresolved external symbol "class sf::Time __cdecl sf::operator-(class sf::Time,class sf::Time)" (??Gsf@@YA?AVTime@0@V10@0@Z) referenced in function "public: void __thiscall sf::Window::display(void)" (?display@Window@sf@@QAEXXZ)   

Error   5   error LNK2019: unresolved external symbol "public: __thiscall sf::Clock::Clock(void)" (??0Clock@sf@@QAE@XZ) referenced in function "public: __thiscall sf::Window::Window(void)" (??0Window@sf@@QAE@XZ)   

Error   6   error LNK2001: unresolved external symbol "public: __thiscall sf::Clock::Clock(void)" (??0Clock@sf@@QAE@XZ)   

Error   7   error LNK2019: unresolved external symbol "public: class sf::Time __thiscall sf::Clock::getElapsedTime(void)const " (?getElapsedTime@Clock@sf@@QBE?AVTime@2@XZ) referenced in function "public: void __thiscall sf::Window::display(void)" (?display@Window@sf@@QAEXXZ)   

Error   8   error LNK2001: unresolved external symbol "public: class sf::Time __thiscall sf::Clock::getElapsedTime(void)const " (?getElapsedTime@Clock@sf@@QBE?AVTime@2@XZ)   

Error   9   error LNK2019: unresolved external symbol "public: class sf::Time __thiscall sf::Clock::restart(void)" (?restart@Clock@sf@@QAE?AVTime@2@XZ) referenced in function "public: void __thiscall sf::Window::display(void)" (?display@Window@sf@@QAEXXZ)   

Error   10   error LNK2001: unresolved external symbol "public: class sf::Time __thiscall sf::Clock::restart(void)" (?restart@Clock@sf@@QAE?AVTime@2@XZ)   

Error   11   error LNK2019: unresolved external symbol "void __cdecl sf::sleep(class sf::Time)" (?sleep@sf@@YAXVTime@1@@Z) referenced in function "public: void __thiscall sf::Window::display(void)" (?display@Window@sf@@QAEXXZ)   

Error   12   error LNK2001: unresolved external symbol "void __cdecl sf::sleep(class sf::Time)" (?sleep@sf@@YAXVTime@1@@Z)   

Error   13   error LNK2019: unresolved external symbol "class std::basic_ostream<char,struct std::char_traits<char> > & __cdecl sf::err(void)" (?err@sf@@YAAAV?$basic_ostream@DU?$char_traits@D@std@@@std@@XZ) referenced in function "public: void __thiscall sf::Window::create(class sf::VideoMode,class sf::String const &,unsigned int,struct sf::ContextSettings const &)" (?create@Window@sf@@QAEXVVideoMode@2@ABVString@2@IABUContextSettings@2@@Z)

Error   14   error LNK2001: unresolved external symbol "class std::basic_ostream<char,struct std::char_traits<char> > & __cdecl sf::err(void)" (?err@sf@@YAAAV?$basic_ostream@DU?$char_traits@D@std@@@std@@XZ)   

Error   15   error LNK2001: unresolved external symbol "class std::basic_ostream<char,struct std::char_traits<char> > & __cdecl sf::err(void)" (?err@sf@@YAAAV?$basic_ostream@DU?$char_traits@D@std@@@std@@XZ)   

Error   16   error LNK2001: unresolved external symbol "public: static class sf::Time const sf::Time::Zero" (?Zero@Time@sf@@2V12@B)   

Error   17   error LNK2019: unresolved external symbol "public: __thiscall sf::Mutex::Mutex(void)" (??0Mutex@sf@@QAE@XZ) referenced in function "void __cdecl `anonymous namespace'::`dynamic initializer for 'mutex''(void)" (??__Emutex@?A0xb322dca2@@YAXXZ)

Error   18   error LNK2001: unresolved external symbol "public: __thiscall sf::Mutex::Mutex(void)" (??0Mutex@sf@@QAE@XZ)   

Error   19   error LNK2001: unresolved external symbol "public: __thiscall sf::Mutex::Mutex(void)" (??0Mutex@sf@@QAE@XZ)

Error   20   error LNK2019: unresolved external symbol "public: __thiscall sf::Mutex::~Mutex(void)" (??1Mutex@sf@@QAE@XZ) referenced in function "void __cdecl `anonymous namespace'::`dynamic atexit destructor for 'mutex''(void)" (??__Fmutex@?A0xb322dca2@@YAXXZ)   

Error   21   error LNK2001: unresolved external symbol "public: __thiscall sf::Mutex::~Mutex(void)" (??1Mutex@sf@@QAE@XZ)   

Error   22   error LNK2001: unresolved external symbol "public: __thiscall sf::Mutex::~Mutex(void)" (??1Mutex@sf@@QAE@XZ)   

Error   23   error LNK2019: unresolved external symbol "public: __thiscall sf::Lock::Lock(class sf::Mutex &)" (??0Lock@sf@@QAE@AAVMutex@1@@Z) referenced in function "protected: __thiscall sf::GlResource::GlResource(void)" (??0GlResource@sf@@IAE@XZ

Error   24   error LNK2001: unresolved external symbol "public: __thiscall sf::Lock::Lock(class sf::Mutex &)" (??0Lock@sf@@QAE@AAVMutex@1@@Z)

Error   25   error LNK2001: unresolved external symbol "public: __thiscall sf::Lock::Lock(class sf::Mutex &)" (??0Lock@sf@@QAE@AAVMutex@1@@Z)   

Error   26   error LNK2019: unresolved external symbol "public: __thiscall sf::Lock::~Lock(void)" (??1Lock@sf@@QAE@XZ) referenced in function "protected: __thiscall sf::GlResource::GlResource(void)" (??0GlResource@sf@@IAE@XZ)   

Error   27   error LNK2001: unresolved external symbol "public: __thiscall sf::Lock::~Lock(void)" (??1Lock@sf@@QAE@XZ)   

Error   28   error LNK2001: unresolved external symbol "public: __thiscall sf::Lock::~Lock(void)" (??1Lock@sf@@QAE@XZ)   

Error   29   error LNK2019: unresolved external symbol "public: __thiscall sf::ThreadLocal::ThreadLocal(void *)" (??0ThreadLocal@sf@@QAE@PAX@Z) referenced in function "public: __thiscall sf::ThreadLocalPtr<class sf::priv::GlContext>::ThreadLocalPtr<class sf::priv::GlContext>(class sf::priv::GlContext *)" (??0?$ThreadLocalPtr@VGlContext@priv@sf@@@sf@@QAE@PAVGlContext@priv@1@@Z)   

Error   30   error LNK2019: unresolved external symbol "public: __thiscall sf::ThreadLocal::~ThreadLocal(void)" (??1ThreadLocal@sf@@QAE@XZ) referenced in function "public: __thiscall sf::ThreadLocalPtr<class sf::priv::GlContext>::~ThreadLocalPtr<class sf::priv::GlContext>(void)" (??1?$ThreadLocalPtr@VGlContext@priv@sf@@@sf@@QAE@XZ)   

Error   31   error LNK2019: unresolved external symbol "public: void __thiscall sf::ThreadLocal::setValue(void *)" (?setValue@ThreadLocal@sf@@QAEXPAX@Z) referenced in function "public: class sf::ThreadLocalPtr<class sf::priv::GlContext> & __thiscall sf::ThreadLocalPtr<class sf::priv::GlContext>::operator=(class sf::priv::GlContext *)" (??4?$ThreadLocalPtr@VGlContext@priv@sf@@@sf@@QAEAAV01@PAVGlContext@priv@1@@Z)   

Error   32   error LNK2019: unresolved external symbol "public: void * __thiscall sf::ThreadLocal::getValue(void)const " (?getValue@ThreadLocal@sf@@QBEPAXXZ) referenced in function "public: __thiscall sf::ThreadLocalPtr<class sf::priv::GlContext>::operator class sf::priv::GlContext *(void)const " (??B?$ThreadLocalPtr@VGlContext@priv@sf@@@sf@@QBEPAVGlContext@priv@1@XZ)   

Error   33   error LNK2019: unresolved external symbol "class sf::Time __cdecl sf::milliseconds(int)" (?milliseconds@sf@@YA?AVTime@1@H@Z) referenced in function "public: bool __thiscall sf::priv::WindowImpl::popEvent(class sf::Event &,bool)" (?popEvent@WindowImpl@priv@sf@@QAE_NAAVEvent@3@_N@Z)   

Error   34   error LNK2001: unresolved external symbol "class sf::Time __cdecl sf::milliseconds(int)" (?milliseconds@sf@@YA?AVTime@1@H@Z)

Error   35   error LNK2019: unresolved external symbol "public: class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > __thiscall sf::String::toAnsiString(class std::locale const &)const " (?toAnsiString@String@sf@@QBE?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@ABVlocale@4@@Z) referenced in function "public: __thiscall sf::priv::WindowImplWin32::WindowImplWin32(class sf::VideoMode,class sf::String const &,unsigned int)" (??0WindowImplWin32@priv@sf@@QAE@VVideoMode@2@ABVString@2@I@Z)

Error   36   error LNK2019: unresolved external symbol "public: class std::basic_string<wchar_t,struct std::char_traits<wchar_t>,class std::allocator<wchar_t> > __thiscall sf::String::toWideString(void)const " (?toWideString@String@sf@@QBE?AV?$basic_string@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@XZ) referenced in function "public: __thiscall sf::priv::WindowImplWin32::WindowImplWin32(class sf::VideoMode,class sf::String const &,unsigned int)" (??0WindowImplWin32@priv@sf@@QAE@VVideoMode@2@ABVString@2@I@Z)   

Error   37   error LNK2019: unresolved external symbol "bool __cdecl sf::operator>(class sf::Time,class sf::Time)" (??Osf@@YA_NVTime@0@0@Z) referenced in function "public: static bool __cdecl sf::priv::JoystickImpl::isConnected(unsigned int)" (?isConnected@JoystickImpl@priv@sf@@SA_NI@Z)   

Error   38   error LNK1120: 22 unresolved externals


Can somebody tell me what I am doing wrong? I have searched the web for solutions for 2 days already and have not been able to fix it. Based on the other websites, I can conclude that some of the code in my main() function has been typed wrong, but I can't figure out what. I have also experimented with it and found that the source of all of the errors is in Line 5, where I make the window.

FRex

  • Hero Member
  • *****
  • Posts: 1848
  • Back to C++ gamedev with SFML in May 2023
    • View Profile
    • Email
Re: I'm Getting Error LNK2019 When Compiling sf::Window
« Reply #1 on: July 06, 2013, 02:17:35 am »
Link to system too. Window depends on it.
Linker errors mean that your code is fine, code that doesn't compile doesn't get to linking part.
Back to C++ gamedev with SFML in May 2023

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6287
  • Thor Developer
    • View Profile
    • Bromeon
Re: I'm Getting Error LNK2019 When Compiling sf::Window
« Reply #2 on: July 06, 2013, 10:32:01 am »
Linker errors mean that your code is fine
No. There are many mistakes that can trigger linker errors, e.g. undefined functions.
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

efeman

  • Newbie
  • *
  • Posts: 8
    • View Profile
Re: I'm Getting Error LNK2019 When Compiling sf::Window
« Reply #3 on: July 18, 2013, 02:01:56 am »
Have you verified that the project properties are set up correctly? It looks like you've done the include directories, but the linker isn't set correctly so it can't find the definitions of those functions. Check the tutorial for your IDE again and make sure to set the libraries and library directories correctly.