what are the reasons that I can get this error?
//error message
1>cLoginServer.obj : error LNK2019: unresolved external symbol "public: __thiscall cServer<unsigned short,class cUser4Login>::cServer<unsigned short,class cUser4Login>(class cUser4Login &)" (??0?$cServer@GVcUser4Login@@@@QAE@AAVcUser4Login@@@Z) referenced in function "public: __thiscall cLoginServer::cLoginServer(void)" (??0cLoginServer@@QAE@XZ)
1>cLoginServer.obj : error LNK2019: unresolved external symbol "public: __thiscall cServer<unsigned short,unsigned short>::cServer<unsigned short,unsigned short>(void)" (??0?$cServer@GG@@QAE@XZ) referenced in function "public: __thiscall cLoginServer::cLoginServer(void)" (??0cLoginServer@@QAE@XZ)
1>cLoginServer.obj : error LNK2019: unresolved external symbol "public: void __thiscall cServer<unsigned short,class cUser4Login>::grow_to(unsigned int)" (?grow_to@?$cServer@GVcUser4Login@@@@QAEXI@Z) referenced in function "public: void __thiscall cLoginServer::LoadConfigFile(void)" (?LoadConfigFile@cLoginServer@@QAEXXZ)
1>cLoginServer.obj : error LNK2019: unresolved external symbol "public: unsigned int __thiscall cServer<unsigned short,class cUser4Login>::capacity(void)" (?capacity@?$cServer@GVcUser4Login@@@@QAEIXZ) referenced in function "public: void __thiscall cLoginServer::SaveConfigFile(void)" (?SaveConfigFile@cLoginServer@@QAEXXZ)
1>cLoginServer.obj : error LNK2019: unresolved external symbol "public: unsigned int __thiscall cServer<unsigned short,unsigned short>::capacity(void)" (?capacity@?$cServer@GG@@QAEIXZ) referenced in function "public: void __thiscall cLoginServer::ShutDown(unsigned char)" (?ShutDown@cLoginServer@@QAEXE@Z)
1>cLoginServer.obj : error LNK2019: unresolved external symbol "public: void __thiscall cServer<unsigned short,class cUser4Login>::remove(unsigned short)" (?remove@?$cServer@GVcUser4Login@@@@QAEXG@Z) referenced in function "public: void __thiscall cLoginServer::LogOut(unsigned short)" (?LogOut@cLoginServer@@QAEXG@Z)
1>cLoginServer.obj : error LNK2019: unresolved external symbol "public: void __thiscall cServer<unsigned short,unsigned short>::remove(unsigned short)" (?remove@?$cServer@GG@@QAEXG@Z) referenced in function "public: void __thiscall cLoginServer::LogOutOf(unsigned short)" (?LogOutOf@cLoginServer@@QAEXG@Z)
1>cLoginServer.obj : error LNK2019: unresolved external symbol "public: unsigned short __thiscall cServer<unsigned short,unsigned short>::insert(unsigned short)" (?insert@?$cServer@GG@@QAEGG@Z) referenced in function "public: bool __thiscall cLoginServer::LogInTo(unsigned short,unsigned char)" (?LogInTo@cLoginServer@@QAE_NGE@Z)
1>cLoginServer.obj : error LNK2019: unresolved external symbol "public: unsigned short & __thiscall cServer<unsigned short,unsigned short>::operator[](unsigned short const &)" (??A?$cServer@GG@@QAEAAGABG@Z) referenced in function "public: bool __thiscall cLoginServer::Kick(unsigned char,unsigned short,unsigned char)" (?Kick@cLoginServer@@QAE_NEGE@Z)
1>cLoginServer.obj : error LNK2019: unresolved external symbol "public: void __thiscall cServer<unsigned short,unsigned short>::grow_to(unsigned int)" (?grow_to@?$cServer@GG@@QAEXI@Z) referenced in function "public: bool __thiscall cLoginServer::CreateServer(unsigned int,unsigned int,unsigned char,char *,unsigned int,unsigned char)" (?CreateServer@cLoginServer@@QAE_NIIEPADIE@Z)
1>cLoginServer.obj : error LNK2019: unresolved external symbol "public: void __thiscall cServer<unsigned short,unsigned short>::clear(void)" (?clear@?$cServer@GG@@QAEXXZ) referenced in function "public: bool __thiscall cLoginServer::CreateServer(unsigned int,unsigned int,unsigned char,char *,unsigned int,unsigned char)" (?CreateServer@cLoginServer@@QAE_NIIEPADIE@Z)
1>cLoginServer.obj : error LNK2019: unresolved external symbol "public: unsigned short __thiscall cServer<unsigned short,class cUser4Login>::insert(class cInfo &)" (?insert@?$cServer@GVcUser4Login@@@@QAEGAAVcInfo@@@Z) referenced in function "public: bool __thiscall cLoginServer::ProcessPacket(class cDataPacket *)" (?ProcessPacket@cLoginServer@@QAE_NPAVcDataPacket@@@Z)
those function calls that the compiler cannot find are my own, not a library's.
the declarations of the functions are in a header file and the definitions are in .cpp file. I would post the code, but it would go beyond the length allowed. I just need to know some things to check. I have been looking around the forums and found that most people have problems with linking librarys, but this is not a library linking problem.
1. cLoginServer.cpp should include the header file where the declarations are.
2. The header file should declare the functions with the "extern" keyword.
the loginserver.cpp does include the header where the functions are declared.
the functions are declared inside of a class inside the header file named cServer.h
the functions are declared inside of a class cServer
and I declare all the functions inside the class header file then the definitions are inside of their own .cpp file
any other reasons for the unresolved external symbol error?
I found the class that is causing the errors, its short enough that I can post the code take a look at this
... why would this error be caused?
1>mathtest.obj : error LNK2019: unresolved external symbol "public: __thiscall cId<int,int>::cId<int,int>(int,int)" (??0?$cId@HH@@QAE@HH@Z) referenced in function _wmain
He has included tester.h in main.cpp anyway.
If the compiler cannot find a template function - it puts a marker sameway as it does for any normal missing function definition and let the linker sort it out.
If he compiles the tester.cpp file (the way I have shown) then the explicit instantiation of
the cId class will cretae the functions for all the instatiable functions in the class and
there will be no linker problems.