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.
I am getting an error that I do not understand.
Here is the compilation output:
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 -
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
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
Here is the code (the main file doesn't even call this objects for now):
//
// ClosetItem.h
// stw
//
#ifndef stw_ClosetItem_h
#define stw_ClosetItem_h
#include <iostream>
class LeakChecker {
int count;
public:
LeakChecker() : count(0) {}
void print() {
std::cout << count << 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 <iostream>
ClosetItem::ClosetItem(int identifier){
lc++;
std::cout<<"ClosetItem #";
lc.print();
}
Can anyone point me out the problem please?