ld: duplicate symbol _user in /Users/bstephens129/Library/Developer/Xcode/DerivedData/full_rpg_text_based-hfrarhgxxzksdfcplpkbmbvolusb/Build/Intermediates/full_rpg_text_based.build/Debug/full_rpg_text_based.build/Objects-normal/x86_64/storyboard.o and /Users/bstephens129/Library/Developer/Xcode/DerivedData/full_rpg_text_based-hfrarhgxxzksdfcplpkbmbvolusb/Build/Intermediates/full_rpg_text_based.build/Debug/full_rpg_text_based.build/Objects-normal/x86_64/main.o for architecture x86_64
Command /Developer/usr/bin/clang++ failed with exit code 1
it says im double-declaring 'user,' but i dont see anywhere that could be happening... help!
main.cpp
1 2 3 4 5 6 7 8 9 10 11 12
#include <iostream>
#include "storyboard.h"
usingnamespace std;
int main (int argc, constchar * argv[])
{
sleep(1);
storyboard::cutscene(1);
return 0;
}
#ifndef full_rpg_text_based_character_h
#define full_rpg_text_based_character_h
#include <strings.h>
usingnamespace std;
class character
{
public:
string name;
int force;
int block;
int stamina;
staticvoid create_user(string nme, int frc, int blk, int sta);
};
character user;
#endif
character.cpp
1 2 3 4 5 6 7 8 9 10 11 12 13
#include <iostream>
#include "character.h"
void character::create_user(string nme, int frc, int blk, int sta)
{
user.name = nme;
user.force = frc;
user.block = blk;
user.stamina = sta;
}
character user; It is a global variable in character.h. It will be declared in following files: character.cpp (includes character.h), storyboard.cpp (includes storyboard.h which includes character.h) and main.cpp (through storyboard.h)