   Millions error "multiple definition of blabla" (C++)
  Hello, I rewrote my game yesterday, and now I have been trying to fix all errors I got.I'm new to split a big source code to several small source files.Here is one error that I doesn't know what the heck is wrong with..I got a problem with my variables "playerX" and "playerY"I've tried to put int playerX,y in my globals.h/.cpp but then I get some wierd error, then I tried to put it in my main, then it says my player.cpp, classes.cpp and other source files needs it too, and cant find playerX,y.So I get tons of these:  multiple definition of `playerX'   first defined here   multiple definition of `playerY'   first defined here I also get four of these:  [Linker error] undefined reference to `creature' Here is the main.cpphttp://pastebin.se/193481player.cpphttp://pastebin.se/193482classes.hhttp://pastebin.se/193483globals.hhttp://pastebin.se/193484Where should I put my playerX and Y?And to get rid of the errorsI have no idea what I should do.. please help me   
  Check out the "extern" keyword. The idea is that you define the variable in one .c file, then in any others that you want to use it from, you have that same definition, but with an "extern" before it (and no initialization). For example:Program.cint myGlobalVar = 5;OtherFile.cextern int myGlobalVar;//I can use myGlobalVar here, too!The "extern type variable_name;" part can go in a header file if you prefer. It doesn't make a difference to the compiler.   ;  The most likely explanation is that the compiler is now going through the same source file several times. Try using include guards or, with MS compilers, #pragma once.Here  is a problem possibly related to yours.;  I do use guards.Thank you very much, but then I get these errors instead:hundreds of them :P  [Linker error] undefined reference to `playerX' and many others of this kind.Then I tried to but playerX = 0; in my global.cppand I get these:5 C:\Dev-Cpp\Projects\Stora projekt\Ideriks adventure 2\globals.cpp expected constructor, destructor, or type conversion before '=' token 5 C:\Dev-Cpp\Projects\Stora projekt\Ideriks adventure 2\globals.cpp expected `,' or `;' before '=' token In global.cpp"#include "SDL/SDL.h" #include "globals.h" playerX = 0;playerY = 0;"   ;  Esbez has the right answer. The other errors you saw are because you wrote "playerX = 0" instead of "int playerX = 0".   ;  Thanks alot guys, but now I got some new problem  [Linker error] undefined reference to `creature' four of them   ;  Where is 'creature' declared?   ;  In classes.h   ;  I meant the variable named 'creature' which you 'import' using the extern key word, not the class definition (which is a little confusing anyway). As I understood it you were referring to the pointer to a SDL_Surface, right?   ;  Thank you so much everyone! It's working now.WanMaster, Yep, it was that. I spelled creature wrong =PIs there anyway to get popup window?I would like to use that as an error message before my game quits.   