The following code fails to link in 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
}
error LNK2019: unresolved external symbol "__declspec(dllimport) public: int __thiscall QString::toWCharArray(unsigned short *)const " (__imp_?toWCharArray@QString@@QBEHPAG@Z) referenced in function _main
error LNK2019: unresolved external symbol "__declspec(dllimport) public: static class QString __cdecl QString::fromWCharArray(unsigned short const *,int)" (__imp_?fromWCharArray@QString@@SA?AV1@PBGH@Z) referenced in function _main