title: Undefined symbols for architecture x86_64: using a structure defined in header file
body: <p>I'm using xcode 4.2 to build this simple program. I realize there are a lot of post on this error but I haven't found any that answer my problem.<br>
    I am getting an error that I do not understand.<br>
    Here is the compilation output:   </p>
  
  <blockquote>
    <p>Ld /Users/kotoko/Library/Developer/Xcode/DerivedData/stw-gyleohvghcrywgcqkihhkkkqeqnl/Build/Products/Debug/stw normal x86_64
        cd /Users/kotoko/projectos/somethingToWear/stw_v6_xcode/stw
        setenv MACOSX_DEPLOYMENT_TARGET 10.6
        /Developer/usr/bin/llvm-g++-4.2 -arch x86_64 -isysroot /Developer/SDKs/MacOSX10.6.sdk -</p>
    
    <p>L/Users/kotoko/Library/Developer/Xcode/DerivedData/stw-gyleohvghcrywgcqkihhkkkqeqnl/Build/Products/Debug
    -F/Users/kotoko/Library/Developer/Xcode/DerivedData/stw-gyleohvghcrywgcqkihhkkkqeqnl/Build/Products/Debug
    -filelist /Users/kotoko/Library/Developer/Xcode/DerivedData/stw-gyleohvghcrywgcqkihhkkkqeqnl/Build/Intermediates/stw.build/Debug/stw.build/Objects-normal/x86_64/stw.LinkFileList
    -mmacosx-version-min=10.6 -o /Users/kotoko/Library/Developer/Xcode/DerivedData/stw-gyleohvghcrywgcqkihhkkkqeqnl/Build/Products/Debug/stw</p>
    
    <p>Undefined symbols for architecture x86_64:   "ClosetItem::lc",
    referenced from:
          ClosetItem::ClosetItem(int)in ClosetItem.o
          ClosetItem::ClosetItem(int)in ClosetItem.o ld: symbol(s) not found for architecture x86_64 collect2: ld returned 1 exit status</p>
  </blockquote>
  
  <p>Here is the code (the main file doesn't even call this objects for now):</p>
  
  <pre><code>//
  //  ClosetItem.h
  //  stw
  //
  
  #ifndef stw_ClosetItem_h
  #define stw_ClosetItem_h
  
  #include &lt;iostream&gt;
  
  class LeakChecker { 
      int count;
  public: 
      LeakChecker() : count(0) {}
      void print() { 
          std::cout &lt;&lt; count &lt;&lt; std::endl;
      } 
      ~LeakChecker() { print(); } 
      void operator++(int) { count++; } 
      void operator--(int) { count--; }
  };
  
  class ClosetItem{
  
  public:
      ClosetItem(int identifier);
      virtual ~ClosetItem() {};
  
  
  protected:
      static LeakChecker lc;
  };
  #endif
  //
  //  ClosetItem.cpp
  //  stw
  //
  
  #include "ClosetItem.h"
  #include &lt;iostream&gt;
  
  ClosetItem::ClosetItem(int identifier){
      lc++;
      std::cout&lt;&lt;"ClosetItem #";
      lc.print();
  }
  </code></pre>
  
  <p>Can anyone point me out the problem please?</p>