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

Author Topic: LNK2019 : unresolved external symbol  (Read 3643 times)

0 Members and 1 Guest are viewing this topic.

Marcvs

  • Newbie
  • *
  • Posts: 2
    • View Profile
LNK2019 : unresolved external symbol
« on: September 01, 2011, 03:54:25 am »
Hi everyone!
I'm new in this forum and my english is awful (I'm italian)... Please, be patient :)

So... This is my first post and I need your help :(
I try to do the "handling time" tutorial, but the linker gives me an "unresolved external symbol" error (LNK2019). It say that the reference to the namespace Clock (sf::Clock) is unresolved but I'm sure I linked all necessary libraries (sfml-window.lib and sfml-window-d.lib).

This is what I wrote (main.cpp):
Code: [Select]
#include <SFML/Window.hpp>
#include <iostream>

int main() {

sf::Window App(sf::VideoMode(800,600,32),"SFML Window - handling time");

sf::Clock Clock;
float time = 0;

while(App.IsOpened()) {

sf::Event Event;
        while (App.GetEvent(Event)) {
if((Event.Type == sf::Event::KeyPressed) && (Event.Key.Code == sf::Key::Escape))
App.Close();
}

time = Clock.GetElapsedTime();
Clock.Reset();

std::cout << "Elapsed time: " << time << std::endl;

App.Display();
}

return EXIT_SUCCESS;

}


And this is what the linker says:

Code: [Select]
Errore 1 error LNK2019: riferimento al simbolo esterno "public: void __thiscall sf::Clock::Reset(void)" (?Reset@Clock@sf@@QAEXXZ) non risolto nella funzione _main main.obj 6_Window - Handling time
Errore 2 error LNK2019: riferimento al simbolo esterno "public: float __thiscall sf::Clock::GetElapsedTime(void)const " (?GetElapsedTime@Clock@sf@@QBEMXZ) non risolto nella funzione _main main.obj 6_Window - Handling time
Errore 3 error LNK2019: riferimento al simbolo esterno "public: __thiscall sf::Clock::Clock(void)" (??0Clock@sf@@QAE@XZ) non risolto nella funzione _main main.obj 6_Window - Handling time
Errore 4 fatal error LNK1120: 3 esterni non risolti C:\Users\XXX\Documents\Visual Studio 2008\Projects\SFML-1.6\6_Window - Handling time\Debug\6_Window - Handling time.exe 1 6_Window - Handling time


I'm under Windows 7 (64 bit), I use Visual Studio 2008 Pro and the version of the SFML is the 1.6.

What did I wrong? (except my english... :lol:)

Ricky

  • Jr. Member
  • **
  • Posts: 99
    • View Profile
    • Tejada
    • Email
LNK2019 : unresolved external symbol
« Reply #1 on: September 01, 2011, 07:49:27 am »
no hay mas errores?
do you have more errors?
I suspect it could be a linking problem and its not finding the lib in which the
sf::Clock class is

could you give me your linker information like what libs are you linking too (if any)
did you install SFML 1.6 before building?
did you put SFML libs into directories and give paths to them into VS?
this could be the problem

instale sfml y trate de nuevo
Wilt thou yet say before him that slayeth thee, I am God? but thou shalt be a man, and no God, in the hand of him that slayeth thee.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
LNK2019 : unresolved external symbol
« Reply #2 on: September 01, 2011, 08:04:11 am »
Quote
I'm sure I linked all necessary libraries (sfml-window.lib and sfml-window-d.lib)

sf::Clock is in sfml-system.
And don't link both the debug and release version of the same library at the same time ;)
Laurent Gomila - SFML developer

Marcvs

  • Newbie
  • *
  • Posts: 2
    • View Profile
LNK2019 : unresolved external symbol
« Reply #3 on: September 01, 2011, 11:06:01 am »
Thanks for the answers :)

@Ricky
I linked these libraries:

sfml-window.lib (release mode)
sfml-window-d.lib (debug mode)

I added SFML_DYNAMIC in the preprocessor (release mode).

About sfml directories, I followed the first tutorial and everything is working properly.

@Laurent
I know that sf::Clock is in sfml-system, but it's not necessary to link because Window.hpp already does it.
I put .dll files (sfml-window.dll and sfml-system.dll and -d versions) in the directory of the project.

...

I'm stupid. I'm very stupid... :oops:
While I'm writing this post I try to redefine libraries in the linker... I used ';' to separate .lib files when I don't have to do it!

Sorry for the lost time :lol:
Now everything works properly!

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
LNK2019 : unresolved external symbol
« Reply #4 on: September 01, 2011, 11:38:31 am »
Quote
I know that sf::Clock is in sfml-system, but it's not necessary to link because Window.hpp already does it.

window.hpp includes System.hpp, but you still have to link to both libraries explicitely.
Laurent Gomila - SFML developer