c++ - 将 Boost 与 Windows 10 通用应用程序一起使用

标签 c++ boost windows-10 win-universal-app

我正在开发 Windows 10 通用应用程序,主要针对 Windows 手机。尝试使用 boost 时出现如下错误:

boost/asio/detail/impl/win_thread.ipp(48): error C2039: 'TerminateThread': is not a member of '`global namespace''

据我了解,出现此问题是由于使用 Windows 10 通用应用程序不支持的 win32 api 进行 boost 。我尝试了 1.58(当前官方版本)和 1.59(候选版本)。有没有我遗漏的标志?您是否有任何与 boost 和 Windows 通用应用程序支持相关的信息?


我创建了最小程序来重现此错误:

#include <boost/asio.hpp>

int main()
{
    return 0;
}

事实上我得到的第一个错误是:

c:\program files (x86)\windows kits\10\include\10.0.10240.0\um\processthreadsapi.h(491): error C3861: 'FlsAlloc': identifier not found

最佳答案

并非所有 Boost 库都可用于 Windows 通用应用程序。正在努力使更多的人可以与通用应用程序一起使用。这里有更多信息:https://blogs.msdn.microsoft.com/vcblog/2014/07/18/using-boost-libraries-in-windows-store-and-phone-applications/

文章作者 Steven Gates 的评论表明 Boost.Asio 可能使用了被禁止的 API。我无法链接到个别评论,因此在此处部分引用(强调我的):

Steven Gates @Li Ning 82: Boost.ASIO depends on the WinSock API, which just recently is now allowed on Windows Phone 8. However I'd bet that ASIO is using other APIs that are banned, that you'd have to replace.

此外,CreateThread、CreateThreadPool 等在 Windows 通用应用程序中不可用。

综上所述,我将假设您必须使用 Boost.Asio 以外的其他东西,这里有一些可能有帮助的附加信息:

模拟多线程的推荐方法是使用 Task.Run .您也可以使用 TaskFactory.StartNew .

为了完成,这里是 Win32 & COM APIs for Windows Runtime apps 的列表.和 Alternatives to Windows APIs in Windows Runtime apps .

希望这对您有所帮助。

关于c++ - 将 Boost 与 Windows 10 通用应用程序一起使用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31962945/

相关文章:

c++ - 在使用 yacc 和 lex 的 CodeBlocks/Eclipse 中构建 C++ 项目

c++ - 在 Qt Creator 中更改默认工作目录

c++ - Boost 正则表达式抛出复杂性异常,而 std::regex 则不会

c++ - boost 日志 : custom action on rotation of files

windows-10 - 我是否需要保留用于创建 SecondaryTile 的图像?

intellij-idea - IntelliJ Idea 终端在 Windows 10 中损坏

python - 在带有 Windows 10 的 Python 的 Selenium 中打开 Firefox

c++ - 一旦代码进入另一个函数如何保留值

c++ - 将 vector<bool> 转换为十进制(作为字符串)

r - 在 MacOS/CRAN 上构建 R 包时包含 boost tokenizer.hpp 文件时出错