PacketBuilder is a little Class which allow to write into a char* array. The Append Functions:
template <class T>
void PacketBuilder::Append(const T value)
{
memcpy((&m_Buffer) + m_Index, (const void*) &value, sizeof(T));
m_Index += sizeof(T);
}
Compiling without errors. If I call Append and use T as unsigned short (WORD). It works great. If I use T as unsigned char. I get an Linker Error.
m_Builder.Append<unsigned char>(0x01); // Error: LNK1120
m_Builder.Append<unsigned short>(0x0001); // Works
Error from VS2010 (sry i got german vs2010):
error LNK2019: Verweis auf nicht aufgelöstes externes Symbol ""public: void __thiscall PacketBuilder::Append(unsigned char)" (??$Append@E@PacketBuilder@@QAEXE@Z)" in Funktion ""public: void __thiscall Client::DoHandshake(void)" (?DoHandshake@Client@@QAEXXZ)". 1>C:\XXX\C++\SilkroadEmu\Debug\LoginServer.exe : fatal error LNK1120: 1 nicht aufgelöste externe Verweise.
Translated to English:
error LNK2019: Unresolved external symbol ""public: void __thiscall PacketBuilder::Append(unsigned char)" (??$Append@E@PacketBuilder@@QAEXE@Z)" in Function ""public: void __thiscall Client::DoHandshake(void)" (?DoHandshake@Client@@QAEXXZ)". 1>C:\XXX\C++\SilkroadEmu\Debug\LoginServer.exe : fatal error LNK1120: 1 unsresolved external symbol.
LNK1120only tells you the number of unresolved externals. You need to post the entire linker error message, including all theLNK2001messages that come before theLNK1120message. Just telling us the error code is not enough, as there are many, many causes of aLNK2001error. If those error messages refer to code that's not part of your question, you should add a minimal code snippet of those as well. - In silico