C++实用程序::转换在静态链接库中不起作用

C++ utility::conversions is not working in Static Linked Library

本文关键字:链接 不起作用 实用程序 转换 C++ 静态      更新时间:2023-10-16

我有一个 c++ MFC 应用程序。 一切都对我有用,直到我排除了我使用的一些标头并将它们设置在一个单独的静态链接库项目中。 现在,一切都编译正常,但是在运行时,当我尝试使用 cpprest sdk 的 utility::conversions 库时,我收到错误"UTF-8 字符串字符永远不能以 10xxxxxx 开头",对于这个库中的每个函数,我得到一个不同的错误,一切都变成了"无法读取内存"。 但是当我使用 std::to_string(( 时,它工作得很好(位于不同的库中 - 不是 cpprest(。 我做错了什么?

pch.h 文件位于库中,而 MFC 应用将其包含在 pch 中.cpp并将预编译标头配置为"创建"。

// Method in the static library triggered by the MFC app
std::string TradeRecord::toJson(std::string channel)
{
string_t _channel= utility::conversions::to_string_t(channel);
return "";
}

问题是使用链接到我的项目的 cpprest 库的发布 dll 版本,一旦我链接了调试 dll 版本,一切正常。 因此,库版本可能存在问题。