main.cpp:(.text+0x5f): undefined reference to
问题 I try to compile some exercise from a SDL guide. I compile like this: g++ -o main main.cpp -I/usr/local/include/SDL2 -L/usr/local/lib -lSDL2 and i get this: /tmp/cci2rYNF.o: In function `main': main.cpp:(.text+0x5f): undefined reference to `Game::init(char const*, int, int, int, int, int)' collect2: error: ld returned 1 exit status and my code is: main.cpp #include "Game.h" // our Game object Game* g_game = 0; int main(int argc, char* argv[]) { g_game = new Game(); g_game->init("Chapter 1",