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

Author Topic: Error: LNK2019  (Read 18785 times)

0 Members and 2 Guests are viewing this topic.

Wesloth

  • Newbie
  • *
  • Posts: 2
    • View Profile
Error: LNK2019
« on: February 28, 2008, 10:56:09 pm »
Hi,
I am really new to C++, so i hope you can help me with my problem.
I tried the tutorial and at beginning all worked well.
This worked well:
Code: [Select]
#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;
}

After that i tried this one:
Code: [Select]
include <SFML/Window.hpp>
#include <iostream>

int main()
{
    sf::Window App(sf::VideoMode(800, 600, 32), "SFML Window");
    return 0;
}

But my IDE said:
Quote
Blub.obj : error LNK2019: Verweis auf nicht aufgelöstes externes Symbol ""public: virtual __thiscall sf::Window::~Window(void)" (??1Window@sf@@UAE@XZ)" in Funktion "_main".
Blub.obj : error LNK2019: Verweis auf nicht aufgelöstes externes Symbol ""public: __thiscall sf::Window::Window(class sf::VideoMode,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,unsigned long,int)" (??0Window@sf@@QAE@VVideoMode@1@ABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@KH@Z)" in Funktion "_main".
Blub.obj : error LNK2019: Verweis auf nicht aufgelöstes externes Symbol ""public: __thiscall sf::VideoMode::VideoMode(unsigned int,unsigned int,unsigned int)" (??0VideoMode@sf@@QAE@III@Z)" in Funktion "_main".

And i dont know what this should be :shock:

Sorry for my english, it's not my native language.

dabo

  • Sr. Member
  • ****
  • Posts: 260
    • View Profile
    • http://www.dabostudios.net
Error: LNK2019
« Reply #1 on: February 29, 2008, 12:36:04 am »
have you added all the necessary additional dependencies?

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Error: LNK2019
« Reply #2 on: February 29, 2008, 02:12:59 am »
To use the Window package, you must link to sfml-window in addition to sfml-system.
Laurent Gomila - SFML developer

Wesloth

  • Newbie
  • *
  • Posts: 2
    • View Profile
Error: LNK2019
« Reply #3 on: February 29, 2008, 12:15:33 pm »
Quote from: "Laurent"
To use the Window package, you must link to sfml-window in addition to sfml-system.

Thanks, that helped.
But now i get the error:
Quote
LINK : fatal error LNK1104: Filei "sfml-window.obj" can not be opened.


edit:
And when i, instead of sfml-window, write sfml-window.lib i get this :shock:
Quote
LINK : warning LNK4098: Standardlibrary "MSVCRT" is in conflict with other libraries; /NODEFAULTLIB:library use.
sfml-window.lib(Window.obj) : error LNK2019:""public: void __thiscall sf::Clock::Reset(void)" (?Reset@Clock@sf@@QAEXXZ)" in function ""public: void __thiscall sf::Window::Display(void)" (?Display@Window@sf@@QAEXXZ)".
sfml-window.lib(Window.obj) : error LNK2019:""void __cdecl sf::Sleep(float)" (?Sleep@sf@@YAXM@Z)" in function ""public: void __thiscall sf::Window::Display(void)" (?Display@Window@sf@@QAEXXZ)".
sfml-window.lib(Window.obj) : error LNK2019:""public: float __thiscall sf::Clock::GetElapsedTime(void)const " (?GetElapsedTime@Clock@sf@@QBEMXZ)" in function ""public: void __thiscall sf::Window::Display(void)" (?Display@Window@sf@@QAEXXZ)".
sfml-window.lib(Window.obj) : error LNK2019:""public: __thiscall sf::Clock::Clock(void)" (??0Clock@sf@@QAE@XZ)" in function ""public: __thiscall sf::Window::Window(void)" (??0Window@sf@@QAE@XZ)".
sfml-window.lib(VideoModeSupport.obj) : error LNK2019: "__imp__EnumDisplaySettingsA@12" in function ""public: static class sf::VideoMode __cdecl sf::priv::VideoModeSupport::GetDesktopVideoMode(void)" (?GetDesktopVideoMode@VideoModeSupport@priv@sf@@SA?AVVideoMode@3@XZ)".
sfml-window.lib(WindowImplWin32.obj) : error LNK2019: "__imp__SwapBuffers@4" in function ""private: virtual void __thiscall sf::priv::WindowImplWin32::Display(void)" (?Display@WindowImplWin32@priv@sf@@EAEXXZ)".
]

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Error: LNK2019
« Reply #4 on: February 29, 2008, 04:34:57 pm »
You must still link with sfml-system.lib.

And if you compile in debug configuration, you must use debug libraries instead (sfml-window-d.lib and sfml-system-d.lib).
Laurent Gomila - SFML developer

j70141

  • Newbie
  • *
  • Posts: 10
    • View Profile
Error: LNK2019
« Reply #5 on: March 28, 2008, 06:38:39 am »
Quote from: "Laurent"
You must still link with sfml-system.lib.

And if you compile in debug configuration, you must use debug libraries instead (sfml-window-d.lib and sfml-system-d.lib).


For all the newbies out there, I found that I also had to turn off Precompiled Headers, in Visual Studio 2008, in order to get my first sample program to work.

Click on Project -> Project Properties
Go to Configuration Properties -> C/C++ -> Precompiled Headers
Change Create/Use Precompiled Header to "Not Using Precompiled Headers"

If this information is wrong, I appologize.   But it is what I had to do in order to get it to work for me.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Error: LNK2019
« Reply #6 on: March 28, 2008, 07:56:10 am »
I don't think there's something in SFML that prevents from using precompiled headers. Maybe you just didn't use it properly ;)
Laurent Gomila - SFML developer

eleinvisible

  • Newbie
  • *
  • Posts: 47
    • View Profile
Error: LNK2019
« Reply #7 on: April 15, 2008, 11:52:02 pm »
Bit late response here: In your second source code you forgot the # before include...