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

Author Topic: Joystick Identification  (Read 3605 times)

0 Members and 1 Guest are viewing this topic.

dabbertorres

  • Hero Member
  • *****
  • Posts: 505
    • View Profile
    • website/blog
Joystick Identification
« on: June 29, 2014, 11:02:47 pm »
I'm sorry if I'm missing something obvious, but, with this code:
#include <SFML/Window.hpp>
#include <iostream>
#include <string>

int main()
{
        std::cout       << "Joystick #" << 0 << " connected:\n"
                                << "Name:\t" << static_cast<std::string>(sf::Joystick::getIdentification(0).name) << '\n'
                                << "Vendor:\t" << sf::Joystick::getIdentification(0).vendorId << '\n'
                                << "Product:\t" << sf::Joystick::getIdentification(0).productId << '\n';
       
        return 0;
}
 

Command to compile: g++ main.cpp -lsfml-system -lsfml-window

I am getting an undefined reference to sf::Joystick::getIdentification(unsigned int).
The rest of the Joystick functions seem alright.

OS: Arch Linux x86_64
Kernel: 3.15.1
g++: 4.9.0-20140604
SFML: latest from github (d73418261b)

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6287
  • Thor Developer
    • View Profile
    • Bromeon
Re: Joystick Identification
« Reply #1 on: June 30, 2014, 12:31:58 am »
You probably have an outdated library lying around. Clear everything and recompile the latest Git revision of SFML.

Maybe a bit offtopic, but I recently wondered if newer g++ versions can cope with arbitrary library orders? Because I have always made the experience that dependent libraries (sfml-window) have to be listed prior to their dependencies (sfml-system).
« Last Edit: June 30, 2014, 12:34:32 am by Nexus »
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

Jebbs

  • Sr. Member
  • ****
  • Posts: 358
  • DSFML Developer
    • View Profile
    • Email
Re: Joystick Identification
« Reply #2 on: June 30, 2014, 02:08:39 am »
Maybe a bit offtopic, but I recently wondered if newer g++ versions can cope with arbitrary library orders? Because I have always made the experience that dependent libraries (sfml-window) have to be listed prior to their dependencies (sfml-system).

I'm pretty sure that is still the case. I use 4.8, and order still matters. I doubt that would have changed.
DSFML - SFML for the D Programming Language.

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11034
    • View Profile
    • development blog
    • Email
Re: Joystick Identification
« Reply #3 on: June 30, 2014, 12:40:46 pm »
As kind of pointed out, your link order is wrong. It should be:

g++ main.cpp -lsfml-window -lsfml-system

Can be easily remember as sfml-window depends on sfml-system.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

dabbertorres

  • Hero Member
  • *****
  • Posts: 505
    • View Profile
    • website/blog
Re: Joystick Identification
« Reply #4 on: June 30, 2014, 08:46:35 pm »
Turns out I had some old SFML libraries in /usr/lib. So getting rid of those fixed it.

And about the order, I've found it funny my system seems to be okay with doing it the wrong way. It works, and trying the executable on other systems works as well, so I'm not complaining. (I normally do it the right way, just typed it wrong here.)

Thanks for the answers.