Crow icon indicating copy to clipboard operation
Crow copied to clipboard

Support for boost asio

Open nlyan opened this issue 2 years ago • 8 comments

Hi guys,

What's the story with 3a485078b85b61f1f49fb4466d5a7d350e155fc6? Is the Boost version of ASIO no longer going to be supported?

It would be preferable in my view, given that Boost is a dependency for so many code bases for other reasons, that the Boost flavor is still supported, otherwise you're just forcing an additional dependency on users.

nlyan avatar Jun 29 '22 10:06 nlyan

Well The commit you're referencing is part of #482 which is a follow up to #457.

And while I wouldn't use the word support (since Crow is using, not supporting a dependency), yes, the idea is to get off of boost and use the standalone ASIO library instead.

I understand that since some people have boost, why bother installing ASIO. But there are also 2 other categories of people, one that doesn't have boost installed, and another that dislikes boost for being a massive package.

I would love to flip a switch and have both versions working, unfortunately if you look at #457, it is not at all the case.

The-EDev avatar Jun 29 '22 12:06 The-EDev

A lot of the deboostification is about migration to std:: so, makes a lot of sense.

However, Boost.ASIO and vanilla ASIO are esseentially 100% compatible. It seems like the extra work in supporting both would be relatively minor, perhaps just shuffling some includes around, and adding some ifdef's or namespace aliases.

WebSocket++ does this here: https://github.com/zaphoyd/websocketpp/blob/1b11fd301531e6df35a6107c1e8665b1e77a2d8e/websocketpp/common/asio.hpp#L45

Only supporting vanilla asio makes it much more difficult for Crow to share an io_context with other ASIO libraries (e.g. Boost.Beast or RPC frameworks like asio-grpc etc. It also means any future work on asynchronous handlers will be less useful (because you won't be able to compose asynchronous operations with service code that uses Boost.ASIO)

Integrating libraries using different event loop implementations is tricky and painful, and Crow doesn't expose interfaces for making this possible.

Looking at asio vanilla, at just one distro (Manjaro/Arch)

  • ASIO is stable at 1.20.x but Boost is stable at 1.79.x (which incorporates asio 1.22.x).
  • The Boost package is used by 253 other packages
  • The naked asio package is only used by just 8 packages, one of which is WebSocket++

nlyan avatar Jun 29 '22 12:06 nlyan

As the author of the #457 and the follow-up #482 PR, I'll just throw in my opinion too.

I've generally disliked using Boost due to its sheer size. Asio is a part of it, but the rest just isn't needed for Crow, as it can just rely on standard features. That's why I made the push away from Boost as a dependency in favor of standalone Asio.

I agree with you that supporting both would be really cool though. It doesn't feel like too much work to get both up and running. I'll take a look at it when I find the necessary time as there currently are other things I am working on, but it's on my list.

luca-schlecker avatar Jun 29 '22 19:06 luca-schlecker

Trying to understand the above discussion, and sorry if this doesnt belong here, but the https://crowcpp.org/master/getting_started/setup/linux/ says nothing about boost is required, but I cant cmake/make without boost?

TheQue42 avatar Feb 03 '23 11:02 TheQue42

I belong in the camp that doesn't have boost installed by default. The move to the standalone ASIO was great for me as I could drop 37 header dependencies from my project. One thing to note is that the ASIO Standalone (boost dependency free) may not be supported in the future. See chriskohlhoff/asio#1208.

@TheQue42 : I ran into a similar problem in #585. If you're using HEAD then, you no longer need boost. You will need the headers from the ASIO repo. When building make sure your compiler include path can find the headers, and pass the -DASIO_STANDALONE flag.

xia-stan avatar Mar 03 '23 14:03 xia-stan

Thanks for xia-stan, I finally comiple helloworld example as g++ helloworld.cpp -o helloworld -DASIO_STANDALONE -I..\include -ID:\asio-master\asio\include -lws2_32 -lwsock32 on windows10 with mingw32.

8188 avatar Jun 17 '23 09:06 8188

Any update on this? Really unfortunate Crow can't be used with an existing code base already having boost as a dependency.

jbulow avatar Feb 20 '24 09:02 jbulow

No. Actually there are no plans to support boost, but if you need it, feel free to add a pull request containing support for boost::asio.

gittiver avatar Feb 20 '24 20:02 gittiver