您好我需要一個std::wstring
到QString
轉換和我試過的轉換爲std :: wstring的到QString的拋出鏈接錯誤
std::wstring wideString;
QString qtString = QString::fromStdWString(wideString);
最明顯的方式,我得到了錯誤:
Error 2 error LNK2019: unresolved external symbol
"__declspec(dllimport) public: static class QString __cdecl QString::fromStdWString(class std::basic_string<wchar_t,struct std::char_traits<wchar_t>,class std::allocator<wchar_t> > const &)" ([email protected]@@[email protected][email protected][email protected][email protected]@@[email protected][email protected]@@[email protected]@@Z)
referenced in function
"public: void __thiscall FileHandler::deleteDir(class std::basic_string<wchar_t,struct std::char_traits<wchar_t>,class std::allocator<wchar_t> >&,int,unsigned int,bool,bool)" ([email protected]@@[email protected][email protected][email protected]@@[email protected][email protected]@@[email protected]@[email protected])
filehandler.objError 3 fatal error LNK1120: 1 unresolved externals C:\Users\Documents\Visual Studio 2008\Projects\product_dev\deletefiles\Debug\FileHandler.exe
我也嘗試過使用該方法QString::fromWCharArray
:
qstring temp = QString::fromWCharArray(const_cast<wchar_t*>(wideString.c_str()),wideString.size());
呃我得到的是
Error 2 error LNK2019: unresolved external symbol
"__declspec(dllimport) public: static class QString __cdecl QString::fromWCharArray(wchar_t const*,int)" ([email protected]@@[email protected][email protected])
referenced in function
"public: void __thiscall FileHandler::deleteDir(class std::basic_string<wchar_t,struct std::char_traits<wchar_t>,class std::allocator<wchar_t> >&,int,unsigned int,bool,bool)" ([email protected]@@[email protected][email protected][email protected]@@[email protected][email protected]@@[email protected]@[email protected])
filehandler.objError 3 fatal error LNK1120: 1 unresolved externals C:\Users\Documents\Visual Studio 2008\Projects\product_dev\deletefiles\Debug\FileHandler.exe 1
我該如何着手解決這個問題?
我,and a few other people得到此錯誤與選項設置爲*否*。它將它設置爲*是*,它可以編譯,但不知道它在運行時甚至可以工作,或者它實際上發生了什麼變化。 – neuviemeporte 2013-07-03 00:36:10
@neuviemeporte Visual Studio設置應該是「是」還是「否」取決於編譯Qt庫時使用的設置。如果啓動Dependency Walker並將導出中的類型列表與鏈接器錯誤中的類型列表進行比較,則應該看到不匹配('wchar_t'與'unsigned short')。您必須調整您的應用程序的設置以匹配。這對運行時行爲沒有任何影響;它只是指示編譯器爲鏈接器生成一個正確類型的導入條目來解決。 – IInspectable 2014-04-24 12:53:41
嗨,舊帖子,但我在qt創建者[qt 5.8.2]後鏈接cpprest後得到同樣的錯誤。我可以在哪裏設置qt創建者的設置? – Hummingbird 2017-03-27 18:03:41