SFML community forums

Help => Window => Topic started by: dabbertorres on June 29, 2014, 11:02:47 pm

Title: Joystick Identification
Post by: dabbertorres 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)
Title: Re: Joystick Identification
Post by: Nexus 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).
Title: Re: Joystick Identification
Post by: Jebbs 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.
Title: Re: Joystick Identification
Post by: eXpl0it3r 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.
Title: Re: Joystick Identification
Post by: dabbertorres 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.