【发布时间】:2018-11-13 15:51:44
【问题描述】:
以下代码无法在 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:无法解析的外部符号“__declspec(dllimport) public: int __thiscall QString::toWCharArray(unsigned short *)const” (__imp_?toWCharArray@QString@@QBEHPAG@Z) 在函数 _main 中引用
错误 LNK2019:引用了未解析的外部符号“__declspec(dllimport) public: static class QString __cdecl QString::fromWCharArray(unsigned short const *,int)”(__imp_?fromWCharArray@QString@@SA?AV1@PBGH@Z)在函数_main
【问题讨论】:
标签: c++ qt qstring unresolved-external wchar-t