Étrange 'undefined reference'
Bonjour,
J'étais en train de programmer mon petit jeu avec la SFML...tranquille...(à noter que ce n'est pas mon premier et que je ne pense pas que ce soit la SFML qui pose problème, mais passons).
Pour faire simple, j'ai un fichier Lang.h :
Code:
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
| #ifndef LANG_H_INCLUDED
#define LANG_H_INCLUDED
#include <SFML/System/String.hpp>
struct Lang
{
void switchToEN()
{
L_newScore = "NEW RECORD !";
L_pressSPACE = "Press SPACE to start a new game";
L_time = "Elapsed time : ";
L_errors = "Errors : ";
}
void switchToFR()
{
L_newScore = "NOUVEAU RECORD !";
L_pressSPACE = "Appuyez sur ESPACE pour commencer une nouvelle partie";
L_time = "Temps écoulé : ";
L_errors = "Erreurs : ";
}
static sf::String L_newScore;
static sf::String L_pressSPACE;
static sf::String L_time;
static sf::String L_errors;
};
#endif // LANG_H_INCLUDED |
Un fichier Game.h :
Code:
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
| #define GAME_H
#include <ctime>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <SFML/System/Clock.hpp>
#include <SFML/Window/Event.hpp>
#include <SFML/Graphics/RenderWindow.hpp>
#include <SFML/Graphics/Texture.hpp>
#include <SFML/Graphics/Sprite.hpp>
#include <SFML/Graphics/CircleShape.hpp>
#include <SFML/Graphics/RectangleShape.hpp>
#include <SFML/Graphics/Text.hpp>
#include "Lang.h"
class Game
{
public:
Game(std::int8_t difficulty = 1);
~Game();
// blah blah, blah, blablah.
} |
Et un fichier Game.cpp dans lequel j'ai des erreurs :
Code:
1 2 3 4 5 6 7 8 9 10 11
| #include "Game.h"
Game::Game(std::int8_t difficulty) : window(), event(), playing(false), newRecord(false), clock(),
difficultyMode(difficulty), target(0, 0, 50, 50),
t_background(), t_colors(), background(), tip(16),
marlboro(), newScoreMessage(Lang::L_newScore, marlboro, 60), pressSPACEtoContinue(Lang::L_pressSPACE, marlboro), // ERREURS
elapsedTimeText(Lang::L_time, marlboro), elapsedTime("0", marlboro), errorsText(Lang::L_errors, marlboro), errors("0", marlboro) // ERREURS
{
// blah blah blah
} |
Les erreurs sont :
||=== Build: Debug in So close ! (compiler: GNU GCC Compiler) ===|
\main.cpp||In function 'int main()':|
\main.cpp|5|warning: zero as null pointer constant [-Wzero-as-null-pointer-constant]|
obj\Debug\Game.o||In function `ZN4GameC2Ea':|
\Game.cpp|8|undefined reference to `Lang::L_newScore'|
\Game.cpp|8|undefined reference to `Lang::L_pressSPACE'|
\Game.cpp|8|undefined reference to `Lang::L_time'|
\Game.cpp|8|undefined reference to `Lang::L_errors'|
||=== Build failed: 4 error(s), 1 warning(s) (0 minute(s), 3 second(s)) ===|
Je pige pas. Où est le problème ?
Merci d'avance pour votre aide.