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

Author Topic: [SFML 2.0] sf::Keyboard::IsKeyPressed LNK2019 error  (Read 3601 times)

0 Members and 1 Guest are viewing this topic.

Petwoip

  • Newbie
  • *
  • Posts: 4
    • View Profile
[SFML 2.0] sf::Keyboard::IsKeyPressed LNK2019 error
« on: January 29, 2012, 06:19:47 am »
Hey,

I've been setting up SFML2.0 and I've been able to generate a render window with openGL in it. Now I'm trying to take keyboard and mouse input. However, when I try:

sf::Mouse::IsButtonPressed(button);       or
sf::Keyboard::IsKeyPressed(keyCode);

I get:

error LNK2019: unresolved external symbol "__declspec(dllimport) public: static bool __cdecl sf::Keyboard::IsKeyPressed(enum sf::Keyboard::Key)" (__imp_?IsKeyPressed@Keyboard@sf@@SA_NW4Key@12@@Z) referenced in ...
error LNK2019: unresolved external symbol "__declspec(dllimport) public: static bool __cdecl sf::Mouse::IsButtonPressed(enum sf::Mouse::Button)" (__imp_?IsButtonPressed@Mouse@sf@@SA_NW4Button@12@@Z) referenced in ...
(Happens in both release and debug mode. Note: I am using static libraries)

If all of my other SFML2 setup works so far, how come IsKeyPressed and IsButtonPressed do not work?

Thanks!

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
[SFML 2.0] sf::Keyboard::IsKeyPressed LNK2019 error
« Reply #1 on: January 29, 2012, 09:20:03 am »
Do you link to sfml-window?
Laurent Gomila - SFML developer

Petwoip

  • Newbie
  • *
  • Posts: 4
    • View Profile
[SFML 2.0] sf::Keyboard::IsKeyPressed LNK2019 error
« Reply #2 on: January 29, 2012, 09:22:06 am »
Ah, should have mentioned my links (in this order):

opengl32.lib
sfml-audio-s-d.lib
sfml-graphics-s-d.lib
sfml-main-d.lib
sfml-network-s-d.lib
sfml-system-s-d.lib
sfml-window-s-d.lib

I've tried changing the order around a bit, but no difference.
Note: I have release mode versions too.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
[SFML 2.0] sf::Keyboard::IsKeyPressed LNK2019 error
« Reply #3 on: January 29, 2012, 09:40:40 am »
Quote
I am using static libraries

You must define SFML_STATIC ;)
Laurent Gomila - SFML developer

Petwoip

  • Newbie
  • *
  • Posts: 4
    • View Profile
[SFML 2.0] sf::Keyboard::IsKeyPressed LNK2019 error
« Reply #4 on: January 29, 2012, 09:46:11 am »
Aha! I defined SFML_STATIC in one class that uses SFML but not in the other. I added it to the other and now the program compiles.

So from now on will I have to define SFML_STATIC in every class that uses non-header SFML functionality?

texus

  • Hero Member
  • *****
  • Posts: 505
    • View Profile
    • TGUI
    • Email
[SFML 2.0] sf::Keyboard::IsKeyPressed LNK2019 error
« Reply #5 on: January 29, 2012, 10:12:07 am »
You don't have to define it inside your classes.
Take a look at the Getting started tutorials.
The only difference is that you will have to define SFML_STATIC while in the tutorial they show how to define SFML_DYNAMIC.
TGUI: C++ SFML GUI

Petwoip

  • Newbie
  • *
  • Posts: 4
    • View Profile
[SFML 2.0] sf::Keyboard::IsKeyPressed LNK2019 error
« Reply #6 on: January 29, 2012, 10:21:33 am »
Thanks for the tip, definitely comes in handy!