Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Macro BOOST_ASIO_HAS_FILE not defined #409

Open
JRazek opened this issue Feb 16, 2023 · 2 comments
Open

Macro BOOST_ASIO_HAS_FILE not defined #409

JRazek opened this issue Feb 16, 2023 · 2 comments

Comments

@JRazek
Copy link

JRazek commented Feb 16, 2023

I am trying to compile basic program:

#include <boost/asio/basic_stream_file.hpp>
#include <iostream>

auto main() -> int { auto b = boost::asio::basic_stream_file{}; }

g++ ./not_compiling.cpp -std=c++20 -lboost -o boost_testing
I receive following compilation error

$ g++ ./not_compiling.cpp -std=c++20 -lboost -o boost_testing
./not_compiling.cpp: In function ‘int main()’:
./not_compiling.cpp:5:38: error: ‘boost::asio’ has not been declared
    5 | auto main() -> int { auto b = boost::asio::basic_stream_file{}; }

I believe that it is an issue with undefined macro BOOST_ASIO_HAS_FILE.

I've tried installing boost from arch repo, compiling from source on boost-1.81.0/1.80.0 branches with the same result.

extra/boost 1.81.0-3 [installed]
    Free peer-reviewed portable C++ source libraries (development headers)
g++ --version
g++ (GCC) 12.2.1 20230201

Manually defining macro in /usr/include/boost/asio/detail/config.hpp did not help and generated another compilation errors.

Now, why is that macro not defined? How can I fix it?

@Techmeology
Copy link

I ran into the same issue (also on Arch). I was able to work around it by defining BOOST_ASIO_HAS_IO_URING and linking against liburing.

@mclow mclow transferred this issue from boostorg/boost Feb 27, 2023
@Techmeology
Copy link

Techmeology commented Mar 26, 2023

It turns out you should also give BOOST_ASIO_DISABLE_EPOLL, otherwise you can get epoll re-registration: File exists [system:17] under certain circumstances when forking.

From the revision history:

The backend is disabled by default, and must be enabled by defining both ASIO_HAS_IO_URING and ASIO_DISABLE_EPOLL.

Simply defining ASIO_HAS_IO_URING alone will enable the backend without using it for the existing I/O objects. This allows it to be used for I/O objects that require io_uring support, such as files.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants