I'm trying to make an array representing a chess board, and I did it like so (according to the similar solved problems on this site)
board.h
namespace Board {
extern int squares[];
};
board.cpp
#include "board.h"
int Board::squares[64];
Yes, it's suppose to be empty, I'll later fill it with values, but the problem is in my render function that's drawing the sprites, I have to access them to know what to draw
game.cpp
int piece = Board::squares[index];
That did not throw any error when compiling, but when linking it throws... this
/usr/bin/ld: CMakeFiles/cpp-chess.dir/src/game.cpp.o: warning: relocation against `_ZN5Board7squaresE' in read-only section `.text'
/usr/bin/ld: CMakeFiles/cpp-chess.dir/src/game.cpp.o: in function `Game::RenderPiece()':
game.cpp:(.text+0x9d3): undefined reference to `Board::squares'
What can I do? Thanks a lot in advance!