以下代码无法在Visual Studio中链接:
#include <qstring.h>
int main(int argc, char *argv[])
{
const auto qstr = QString::fromWCharArray(L"Hello world!");
auto wstr = new wchar_t[qstr.length() + 1];
const auto wlen = qstr.toWCharArray(wstr);
wstr[wlen] = L'\0';
return 0; // 'wstr' not deleted for simplification
}
错误LNK2019:未解析的外部符号&#34; __ declspec(dllimport)public:int __thiscall QString :: toWCharArray(unsigned short *)const&#34; (__imp_?toWCharArray @ QString @@ QBEHPAG @ Z)在函数_main中引用
错误LNK2019:未解析的外部符号&#34; __ declspec(dllimport)public:静态类QString __cdecl QString :: fromWCharArray(unsigned short const *,int)&#34; (__imp_?fromWCharArray @ QString @@ SA?AV1 @ PBGH @ Z)在函数_main中引用