您好我需要一个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