c++ - 将 QString 与 wchar_t 一起使用时无法解析的外部符号
问题描述
以下代码无法在 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 中引用
解决方案
推荐阅读
- java - java - 如何使用正则表达式防止Java电子邮件字段中的重音字符?
- pip - 如何下载pyaudio
- node.js - npm 安装:500 错误
- python - 将数据从 Python 返回到 Unity 的问题
- c# - 荧光笔墨水笔触未渲染到画布控件上
- search - 在 Flutter 应用程序中搜索不同的 Firestore 集合
- php - 错误:Flutter web 中的 XMLHttpRequest 错误
- mbed - 为 K22F 编译时 USBKeyboard 未定义
- flutter - Flutter - Delete image from GridView with long press and PopupMenu
- c++ - 在 ROS 中使用 cv::FileStorage 加载 YML 文件时出现分段错误