I have a very curious and unique problem here.
I'm creating a parser using bison and flex. i did all the development
work in a linux environment.
the project includes the source files output from flex and bison, then
several cpp files to create a data structure from the parser.
i used gcc as the compiler for the flex output(as it is a c file)
and g++ as the compiler for the remaining source files.
linked all the object files to create the final executable file.
when i tried to port the same to the visual studio with the same
settings
i got error as follows
CSymbolTable.obj : error LNK2005: "struct symrec * __cdecl
returnSymbolTable(void)" (?returnSymbolTable@@YAPAUsymrec@@XZ) already
defined in CSymbolTable.obj
CSymbolTable.obj : error LNK2005: "public: struct symrec * __thiscall
CSymbolTable::returnSymbolTable(void)"
(?returnSymbolTable@CSymbolTable@@QAEPAUsymrec@@XZ ) already defined in
CSymbolTable.obj
CSymbolTable.obj : error LNK2005: "void __cdecl
enter_or_leave_the_struct(int)" (?enter_or_leave_the_struct@@YAXH@Z)
already defined in CSymbolTable.obj
CSymbolTable.obj : error LNK2005: "public: void __thiscall
CSymbolTable::enter_or_leave_the_struct(int)"
(?enter_or_leave_the_struct@CSymbolTable@@QAEXH@Z) already defined in
CSymbolTable.obj
CSymbolTable.obj : error LNK2005: "char * __cdecl
CreateAnUniqueName(char *)" (?CreateAnUniqueName@@YAPADPAD@Z) already
defined in CSymbolTable.obj
CSymbolTable.obj : error LNK2005: "struct symrec * __cdecl putsym(char
*,int,char *,char *)" (?putsym@@YAPAUsymrec@@PADH00@Z) already defined
in CSymbolTable.obj
CSymbolTable.obj : error LNK2005: "public: struct symrec * __thiscall
CSymbolTable::putsym(char *,int,char *,char *)"
(?putsym@CSymbolTable@@QAEPAUsymrec@@PADH00@Z) already defined in
CSymbolTable.obj
CSymbolTable.obj : error LNK2005: "public: __thiscall
CSymbolTable::CSymbolTable(void)" (??0CSymbolTable@@QAE@XZ) already
defined in CSymbolTable.obj
where CSymbolTable.cpp is one of the source files. this happens for
every source file that i use.
i tried to use ifndef directive to avoid multiple inclusion, then i get
lnk2001 error as follows
parser.obj : error LNK2001: unresolved external symbol "public: void
__thiscall CChannels::AddGroupMeas(char *)"
(?AddGroupMeas@CChannels@@QAEXPAD@Z)
parser.obj : error LNK2001: unresolved external symbol "public: void
__thiscall CChannels::AddASubGroup(char *)"
(?AddASubGroup@CChannels@@QAEXPAD@Z)
parser.obj : error LNK2001: unresolved external symbol "public: void
__thiscall CChannels::AddASubGroup(char *)"
(?AddASubGroup@CChannels@@QAEXPAD@Z)
parser.obj : error LNK2001: unresolved external symbol "public: void
__thiscall CChannels::AddGroupChannel(char *)"
(?AddGroupChannel@CChannels@@QAEXPAD@Z)
parser.obj : error LNK2001: unresolved external symbol "public: void
__thiscall CChannels::AddGroupChannel(char *)"
(?AddGroupChannel@CChannels@@QAEXPAD@Z)
parser.obj : error LNK2001: unresolved external symbol "public: void
__thiscall CChannels::AddAChannel(char *)"
(?AddAChannel@CChannels@@QAEXPAD@Z)
it is very frustrating as it is working very well with gcc and g++
any pointers in the right direction will help me a lot.
thanks again
jc