Bonjour,
Je sais que ce titre de message revient souvent et j'aurais aimé trouver la solution sans vous déranger.
Mon application est composée de plusieurs modules, l'un deux se charge des entrées du clavier et des joysticks.
Dans la classe des joysticks j'inclus un autre fichier, dans la définition de la classe, contenant les codes des touches (pour la lisibilité). Ca donne ça :
Le fichier joystick.hpp :
le fichier joy_codes.hpp (sans le block #ifndef ... #define ... #endif puisqu'il est inclus (et ne dois être inclus) uniquement dans la classe joystick) :Code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23 namespace input { /** * \brief A class representing a joystick. */ class joystick : public controller { public: /** \brief Code representing a button on the joystick. */ typedef unsigned int joy_code; public: ... // only for input::system virtual void refresh(); public: #include "input/joy_codes.hpp" ... }; // class joystick } // namespace input
et voici la fonction incriminée, du fichier joystick.cppCode:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37 static const joy_code jc_axis_up = 0; static const joy_code jc_axis_down = 1; static const joy_code jc_axis_left = 2; static const joy_code jc_axis_right = 3; static const joy_code jc_axis_up_left = 4; static const joy_code jc_axis_up_right = 5; static const joy_code jc_axis_down_left = 6; static const joy_code jc_axis_down_right = 7; static const joy_code jc_button_1 = 8; static const joy_code jc_button_2 = 9; static const joy_code jc_button_3 = 10; static const joy_code jc_button_4 = 11; static const joy_code jc_button_5 = 12; static const joy_code jc_button_6 = 13; static const joy_code jc_button_7 = 14; static const joy_code jc_button_8 = 15; static const joy_code jc_button_9 = 16; static const joy_code jc_button_10 = 17; static const joy_code jc_button_11 = 18; static const joy_code jc_button_12 = 19; static const joy_code jc_button_13 = 20; static const joy_code jc_button_14 = 21; static const joy_code jc_button_15 = 22; static const joy_code jc_button_16 = 23; /** * \brief Code representing an invalid code. * \remark Currently the same as c_key_codes_count. */ static const joy_code jc_invalid = 24; /** \brief Number of valid key codes. */ static const unsigned int c_joy_codes_count = 24; /** \brief Number of valid key codes. */ static const unsigned int c_number_of_buttons = 16;
Je compile tout ça et je le met dans une bibliothèque, que je lie au prog principal. Quand je compile le prog, le verdict est :Code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 void input::joystick::refresh() { m_pressed_buttons.clear(); const bool up = SDL_JoystickGetAxis( m_joystick, 1 ) < -1000; const bool down = SDL_JoystickGetAxis( m_joystick, 1 ) > 1000; const bool left = SDL_JoystickGetAxis( m_joystick, 0 ) < -1000; const bool right = SDL_JoystickGetAxis( m_joystick, 0 ) > 1000; if (up) { if (left) m_pressed_buttons.push_back( jc_axis_up_left ); else if (right) m_pressed_buttons.push_back( jc_axis_up_right ); else m_pressed_buttons.push_back( jc_axis_up ); } ... } // joystick::refresh()
Ce qui m'étonne, c'est que j'utilise ces constantes dans une autre méthode de la classe joystick, et que dans celle-ci il n'y a pas de problème. Et aussi que j'utilise le même modèle pour la classe du clavier qui ne pose pas de problèmes non plus.Citation:
../input/lib/libinput.a(joystick.o): dans la fonction « input::joystick::refresh() »:
code/joystick.cpp:162: référence indéfinie vers « input::joystick::jc_axis_up_left »
code/joystick.cpp:164: référence indéfinie vers « input::joystick::jc_axis_up_right »
code/joystick.cpp:166: référence indéfinie vers « input::joystick::jc_axis_up »
code/joystick.cpp:171: référence indéfinie vers « input::joystick::jc_axis_down_left »
code/joystick.cpp:173: référence indéfinie vers « input::joystick::jc_axis_down_right »
code/joystick.cpp:175: référence indéfinie vers « input::joystick::jc_axis_down »
code/joystick.cpp:178: référence indéfinie vers « input::joystick::jc_axis_left »
code/joystick.cpp:180: référence indéfinie vers « input::joystick::jc_axis_right »
Voilà. Là je suis complètement à court d'idées. Qu'est-ce qui se passe ?
Merci pour votre aide.