我有一個解決方案,它由本機C++ DLL和C++/CLI包裝器組成。我的目標是在本機C++ DLL的C++/CLI中創建一個包裝器。混合本機C++和C++/CLI
每當我嘗試在包裝器中創建本機C++類的實例時,遇到很多鏈接器錯誤(請參見下文)。在C++/CLI中的原生C++ DLL
2> .NETFramework,Version=v4.0.AssemblyAttributes.cpp
2>NFileOperation.obj : error LNK2028: unresolved token (0A000208) "public: static bool __cdecl CFileOperation::FileExists(class ATL::CStringT<wchar_t,class ATL::StrTraitATL<wchar_t,class ATL::ChTraitsCRT<wchar_t> > > const &)" ([email protected]@@[email protected][email protected][email protected][email protected]@@@[email protected]@@[email protected]@@Z) referenced in function "[T2M] void __clrcall `dynamic initializer for 'public: static float * tagVARIANT::* ATL::CVarTypeInfo<float *>::pmField''(void)" ([email protected][email protected][email protected]@[email protected]@[email protected]@[email protected]@@[email protected][email protected]@YMXXZ)
2>DeskUpdateManaged.obj : error LNK2028: unresolved token (0A00021C) "public: static bool __cdecl CFileOperation::FileExists(class ATL::CStringT<wchar_t,class ATL::StrTraitATL<wchar_t,class ATL::ChTraitsCRT<wchar_t> > > const &)" ([email protected]@@[email protected][email protected][email protected][email protected]@@@[email protected]@@[email protected]@@Z) referenced in function "public: bool __clrcall DeskUpdateManaged::Conversion::FileExist(class System::String ^)" ([email protected]@[email protected]@[email protected]@@@Z)
2>DeskUpdateManaged.obj : error LNK2019: unresolved external symbol "public: static bool __cdecl CFileOperation::FileExists(class ATL::CStringT<wchar_t,class ATL::StrTraitATL<wchar_t,class ATL::ChTraitsCRT<wchar_t> > > const &)" ([email protected]@@[email protected][email protected]_W[email protected][email protected]@@@[email protected]@@[email protected]@@Z) referenced in function "public: bool __clrcall DeskUpdateManaged::Conversion::FileExist(class System::String ^)" ([email protected]@[email protected]@[email protected]@@@Z)
2>NFileOperation.obj : error LNK2001: unresolved external symbol "public: static bool __cdecl CFileOperation::FileExists(class ATL::CStringT<wchar_t,class ATL::StrTraitATL<wchar_t,class ATL::ChTraitsCRT<wchar_t> > > const &)" ([email protected]@@[email protected][email protected][email protected][email protected]@@@[email protected]@@[email protected]@@Z)
2>C:\Users\ABGZAMANK\Music\DeskUpdate\Dev\Source\Solution\Debug\DeskUpdateManaged.dll : fatal error LNK1120: 3 unresolved externals
函數調用:
bool NFileOperation::FileExists(CAtlString sPathName)
{
return CFileOperation::FileExists(sPathName);
}
是否有更充足的方法是什麼我想達到什麼目的? 任何有關這個問題的建議非常感謝。
您是否將本機庫設置爲CLI鏈接器的輸入? – 2013-02-13 09:23:29
我不確定,如何檢查我是否有? – 2013-02-13 09:45:02
右鍵單擊您的項目 - >屬性 - >連接器。在常規站點上指定其他庫目錄。在輸入站點上指定輸出.lib作爲附加依賴項。 – 2013-02-13 10:00:54