Reputation: 1156
I am trying to compile the c++ code in xcode and I am getting following error:
ld: duplicate symbol _selectedFields in Library/Developer/Xcode/DerivedData/ReadHeaderTBL-arftrodtnbtmucbjkejinzonhulu/Build/Intermediates/ReadHeaderTBL.build/Debug-iphonesimulator/ReadHeaderTBL.build/Objects-normal/i386/readingTBLCPP.o and /Library/Developer/Xcode/DerivedData/ReadHeaderTBL-arftrodtnbtmucbjkejinzonhulu/Build/Intermediates/ReadHeaderTBL.build/Debug-iphonesimulator/ReadHeaderTBL.build/Objects-normal/i386/ReadFile.o for architecture i386
The symbol " selectedFields
" is declared in one class and invoked from other.
It is declared as:
std::string selectedFields;
I am not getting the cause for this error.
Upvotes: 0
Views: 242
Reputation: 8027
Usually when we get this problem it's because people have declared the variable in a header file. You should define it in a header file
extern std::string selectedFields; // definition
and declare it in one source file
std::string selectedFields; // declaration
If your problem is something else then post the code. It gets a bit dispiriting to have to guess what everyone's problem is because they don't bother to post code.
Upvotes: 2