gpt4 book ai didi

C++ Boost 等待无法识别

转载 作者:行者123 更新时间:2023-12-02 01:32:12 28 4
gpt4 key购买 nike

我尝试使用 boost::asio::awaitable 中的 awaitable 但未被识别

error: ‘boost::asio::awaitable’ has not been declared

即使我有 Boost 1.71 并且我在 Ubuntu 19.04 上使用

#include <boost/asio/awaitable.hpp>   //<---- it's working 

boost::asio::awaitable<void> something(){ //<---- error: it's not able to see awaitable

}

这是我的 CMake:

cmake_minimum_required(VERSION 3.14)

project(Project)

message(STATUS "start running cmake...")


set(BOOST_ROOT "boost_1_71_0")
set(Boost_INCLUDE_DIRS "boost_1_71_0")
set(Boost_LIBRARIES "boost_1_71_0/stage/lib")
set(BOOST_SYSTEM "boost_1_71_0/stage/lib/libboost_system.so")
set(BOOST_FILE_SYSTEM "boost_1_71_0/stage/lib/libboost_filesystem.so")


find_package(Boost COMPONENTS system filesystem REQUIRED)
find_package(Boost COMPONENTS system thread)

message(STATUS "Boost_INCLUDE_DIRS: ${Boost_INCLUDE_DIRS}")
message(STATUS "Boost_LIBRARIES: ${Boost_LIBRARIES}")
message(STATUS "Boost_VERSION: ${Boost_VERSION}")
message(STATUS "BOOST_SYSTEM: ${BOOST_SYSTEM}")
message(STATUS "BOOST_FILE_SYSTEM: ${BOOST_FILE_SYSTEM}")

include_directories(${Boost_INCLUDE_DIRS})

add_executable(ServerMain Plugins/PluginInterface.h Plugins/PluginBinary.cpp Plugins/PluginBinary.h Plugins/PluginString.cpp Plugins/PluginString.h Server/Server.cpp Server/Server.h Server/ServerMain.cpp Server/Session.cpp Server/Session.h)
add_executable(ClientMain Client/Client.cpp Client/Client.h Client/ClientMain.cpp Client/Utils.h)

target_link_libraries(ServerMain ${Boost_LIBRARIES})
target_link_libraries(ClientMain ${Boost_LIBRARIES})

target_link_libraries(ServerMain ${BOOST_FILE_SYSTEM} ${BOOST_SYSTEM} pthread)
target_link_libraries(ClientMain ${BOOST_FILE_SYSTEM} ${BOOST_SYSTEM} pthread)

此外,我正在使用 C++17

知道如何才能完成这项工作吗?

最佳答案

你应该使用 clang++,因为 gcc 7/8/9 不支持协程 ts。

关于C++ Boost 等待无法识别,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57938107/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com