Home Extern Variables seemingly not working
 I've been searching through Stackoverflow and the web for the answer and it seems like I'm doing this correctly, however I can't get it to work. I made a test program for using extern, (it's on xCode using the projects feature if that makes a difference). I'm trying to declare a variable, that I can access anywhere in my program, whenever I change the value of that variable, I want to be able to access the changed value. What I've done so far is I have a header file  externFile.h  and a externFile.c  and of course my main.c In externFile.h I defined:  extern int ply;  In main.c I have: int main() { int ply; ply = 5; printPly(); }  In externFile.c I have:  void printPly(){ printf("%d is ply.\n", ply); }  However I'm getting this error:  _ply referenced from _printPly ld symbols not found for architecture x86_64  Does anyone have any sort of ideas about this? EDIT: Thanks for the help Weathervane and Eugene! The problem was that I defined ply inside of main(), instead of outside of the function.