Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using Boost with Windows 10 universal app

I`m developing Windows 10 universal app, mainly targeting Windows phones. When trying to use boost I get errors like this:

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

As far as I understand, this problem occurs due to boost using win32 api which is not supported in Windows 10 universal application. I tried both 1.58 ( current official release) and 1.59 (release candidate). Are there any flags I`m missing? Do you have any information related to boost and Windows universal app support?


I`ve created minimal program to reproduce this error:

#include <boost/asio.hpp>

int main()
{
    return 0;
}

In fact the first error I get is:

c:\program files (x86)\windows kits\10\include\10.0.10240.0\um\processthreadsapi.h(491): error C3861: 'FlsAlloc': identifier not found
like image 791
MarcinG Avatar asked Aug 12 '15 10:08

MarcinG


1 Answers

Not all Boost libraries can be used for Windows Universal Apps. Work to make more of them be usable with Universal apps is ongoing. Here's more information: https://blogs.msdn.microsoft.com/vcblog/2014/07/18/using-boost-libraries-in-windows-store-and-phone-applications/

Post author, Steven Gates, has comments indicating that Boost.Asio is likely using banned APIs. I'm not able to link to individual comments, so partially quoting here (emphasis mine):

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.

Also, CreateThread, CreateThreadPool, etc are not available in Windows Universal apps.

Having said the above, I'm going to assume that you'll have to use something other than Boost.Asio, in which here's some additional info that may help:

The recommended way to simulate multithreading is the use of Task.Run. You can also use TaskFactory.StartNew.

For completion, here's the list of Win32 & COM APIs for Windows Runtime apps. and Alternatives to Windows APIs in Windows Runtime apps.

Hope this helps.

like image 73
Vijay Varadan Avatar answered Nov 04 '22 13:11

Vijay Varadan