我在.h
文件中定義了一個靜態成員函數,該函數工作正常。錯誤LNK2019:將代碼放入cpp文件時無法解析的外部符號
當我試圖將執行文件移動到.cpp
文件時,項目編譯失敗,因爲調用此函數的另一個類發生LNK2019錯誤。
錯誤消息:
8>------ Build started: Project: COrders, Configuration: Debug x64 ------
8> Creating library D:\devel\Server\COrders\Debugx64\COrders.lib and object D:\devel\Server\COrders\Debugx64\COrders.exp
8>OrderProcessor.obj : error LNK2019: unresolved external symbol "public: static bool __cdecl COAValidator::ValidatePercentage(class CSDO const &,class CExecInstHelper const &,class ATL::CStringT<char,class StrTraitMFC_DLL<char,class ATL::ChTraitsCRT<char> > > const &)" ([email protected]@[email protected]@[email protected]@@[email protected][email protected][email protected]@[email protected]@@@@[email protected]@@Z) referenced in function "private: int __cdecl CPlus::COrderProcessor::DoCreate(int)" ([email protected]@[email protected]@[email protected])
8>D:\devel\Server\Server\COrders\Debugx64\COrdersd.dll : fatal error LNK1120: 1 unresolved externals
這裏COrderProcessor::DoCreate()
試圖調用static bool COAValidator::ValidatePercentage()
,其中通過.dll
不知道如何解決它提供?
你能顯示代碼至少在這個方法嗎? –
您是否自己創建了包含'COAValidator :: ValidatePercentage()'的'.dll'?您是否使用'__declspec'標記了此方法的輸出? https://msdn.microsoft.com/en-us/library/a90k134d.aspx – atkins