我在Visual C++應用程序中修改了一個現有類,使其成爲泛型類。此類由另外兩個模塊使用。當我分別編譯這些模塊時,一切正常。C++泛型類鏈接錯誤
1>Linking...
1> Creating library C:\ccmdb\prep\g3_v5.3\g3_tools\fc_tools\ZFRTool\ZStackMTI\Debug\ZStackMTI.lib and object C:\ccmdb\prep\g3_v5.3\g3_tools\fc_tools\ZFRTool\ZStackMTI\Debug\ZStackMTI.exp
1>SerialPort.obj : error LNK2019: unresolved external symbol "public: __thiscall CRingBuffer<unsigned char>::CRingBuffer<unsigned char>(unsigned long)" ([email protected]@@[email protected]@Z) referenced in function "public: __thiscall CSerialPort::CSerialPort(void)" ([email protected]@[email protected])
1>ZStackMTI.obj : error LNK2001: unresolved external symbol "public: __thiscall CRingBuffer<unsigned char>::CRingBuffer<unsigned char>(unsigned long)" ([email protected]@@[email protected]@Z)
1>SerialPort.obj : error LNK2019: unresolved external symbol "public: __thiscall CRingBuffer<unsigned char>::~CRingBuffer<unsigned char>(void)" ([email protected]@@[email protected]) referenced in function "public: void * __thiscall CRingBuffer<unsigned char>::`scalar deleting destructor'(unsigned int)" ([email protected]@@[email protected])
1>ZStackMTI.obj : error LNK2001: unresolved external symbol "public: __thiscall CRingBuffer<unsigned char>::~CRingBuffer<unsigned char>(void)" ([email protected]@@[email protected])
1>SerialPort.obj : error LNK2019: unresolved external symbol "public: unsigned long __thiscall CRingBuffer<unsigned char>::GetBufferItems(void)" ([email protected][email protected]@@QAEKXZ) referenced in function "public: unsigned long __thiscall CSerialPort::GetBufferedRxItems(void)" ([email protected]@@QAEKXZ)
1>SerialPort.obj : error LNK2019: unresolved external symbol "public: int __thiscall CRingBuffer<unsigned char>::Peek(unsigned char *,unsigned long,unsigned long *)" ([email protected][email protected]@@[email protected]) referenced in function "public: unsigned long __thiscall CSerialPort::Peek(unsigned char *,unsigned long,unsigned long *)" ([email protected]@@[email protected])
1>SerialPort.obj : error LNK2019: unresolved external symbol "public: int __thiscall CRingBuffer<unsigned char>::Remove(unsigned char *,unsigned long,unsigned long *)" ([email protected][email protected]@@[email protected]) referenced in function "public: unsigned long __thiscall CSerialPort::Read(unsigned char *,unsigned long,unsigned long *)" ([email protected]@@[email protected])
1>ZStackMTI.obj : error LNK2001: unresolved external symbol "public: int __thiscall CRingBuffer<unsigned char>::Remove(unsigned char *,unsigned long,unsigned long *)" ([email protected][email protected]@@[email protected])
1>SerialPort.obj : error LNK2019: unresolved external symbol "public: int __thiscall CRingBuffer<unsigned char>::Add(unsigned char *,unsigned long,int)" ([email protected][email protected]@@[email protected]) referenced in function "public: unsigned long __thiscall CSerialPort::Write(unsigned char *,unsigned long)" ([email protected]@@[email protected])
1>ZStackMTI.obj : error LNK2001: unresolved external symbol "public: int __thiscall CRingBuffer<unsigned char>::Add(unsigned char *,unsigned long,int)" ([email protected][email protected]@@[email protected])
1>SerialPort.obj : error LNK2019: unresolved external symbol "public: int __thiscall CRingBuffer<unsigned char>::Delete(unsigned long)" ([email protected][email protected]@@[email protected]) referenced in function "public: unsigned long __thiscall CSerialPort::Delete(unsigned long,int)" ([email protected]@@[email protected])
1>SerialPort.obj : error LNK2019: unresolved external symbol "public: int __thiscall CRingBuffer<unsigned char>::Flush(void)" ([email protected][email protected]@@QAEHXZ) referenced in function "public: unsigned long __thiscall CSerialPort::Flush(int)" ([email protected]@@[email protected])
1>ZStackMTI.obj : error LNK2019: unresolved external symbol "public: unsigned char __thiscall CRingBuffer<unsigned char>::Peek(unsigned long)" ([email protected][email protected]@@[email protected]) referenced in function "unsigned long __cdecl ZBNConnect_GetExtAddr(unsigned char *)" ([email protected]@[email protected])
1>C:\ccmdb\prep\g3_v5.3\g3_tools\fc_tools\ZFRTool\ZStackMTI\Debug\ZStackMTI.dll : fatal error LNK1120: 9 unresolved externals
1>Build log was saved at "file://c:\ccmdb\prep\g3_v5.3\g3_tools\fc_tools\ZFRTool\ZStackMTI\ZStackMTI\Debug\BuildLog.htm"
1>ZStackMTI - 14 error(s), 0 warning(s)
我使用Visual Studio 2008。有誰知道如何解決這個問題:然而,當我做了建立所有,我得到這些鏈接錯誤?在修改之前,所有內容和鏈接都沒有任何問題。謝謝。
也許發佈一些類和調用者的代碼? – Cosmin 2011-03-08 19:10:17