async_simple编译测试(一)

文章介绍了如何在Ubuntu18环境下,使用GCC11和CMake3.15+来安装和编译阿里开源的async_simple框架。该框架支持无栈协程、有栈协程和Future/Promise等异步编程组件,适用于图计算、时序数据库和搜索引擎等项目。在安装过程中,涉及了更新GCC、安装CMake、libaio-dev、gtest和gmock等步骤,并给出了编译DEMO工程的方法。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

前言
async_simple 阿里开源的轻量级 C++ 异步框架
提供了基于 C++20 无栈协程(Lazy)、有栈协程(Uthread) 以及 Future/Promise 等异步组件,能够轻松完成 C++ 异步的开发,广泛应用于阿里的图计算引擎、时序数据库、搜索引擎等系统。

1:准备
下载地址 https://github.com/alibaba/async_simple
ubutu18
需要 clang10 或 gcc10 或 Apple-clang14 及其以上版本(这里准备的gcc11)
cmake 3.15及以上

2:安装
官方安装说明(按照说明,实际操作有点问题)
在这里插入图片描述

gcc11 g++11
sudo add-apt-repository ppa:ubuntu-toolchain-r/test
sudo apt-get update
sudo apt-get install gcc-11 g+±11
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-1 110
sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g+±11 110
cmake
sudo snap find cmake
#找到是 3.26.3 最新版(apt-cache madison cmake 得到是3.10.2 无法满足需求)
sudo snap install cmake --classic

make (https://ftp.gnu.org/pub/gnu/make/ 最新版 4.4)
sudo apt-get install make #安装是4.1 (apt-cache 查到是4.1.9 snap 没找到可安装的make)

libaio-dev
sudo apt install libaio-dev -y

使用apt安装gtest、gmock
sudo apt install -y libgtest-dev libgmock-dev
修改为(libgmock-dev 找不到)
sudo apt install -y libgtest-dev gmock

3:编译运行
官方
在这里插入图片描述

cd async_simple # cd 到目录下
mkdir build && cd build
CXX=g++ CC=gcc #这里跟官方说明不一样,
cmake …/ -DCMAKE_BUILD_TYPE=Debug -DASYNC_SIMPLE_ENABLE_TESTS=OFF -DASYNC_SIMPLE_BUILD_DEMO_EXAMPLE=OFF -DASYNC_SIMPLE_DISABLE_AIO=ON

make test (已备忽略了) make install #这里暂时没执行 需要时,直接拷贝过去就行

4:编译DEMO工程

1>async_simple 拷贝到 demo 目录下 主要是 头文件
在这里插入图片描述
2> 上面的 async_simple 毕竟没执行 make install ,所以需要指定头文件路径及 库文件路径
还有就是增加 pthread
在这里插入图片描述

cmake …/
make

在这里插入图片描述

5:测试运行
期待 c++23 ,c++26早点出来,感觉不像go的协程那么方便使用
在这里插入图片描述
如果觉得有用,麻烦点个赞,加个收藏

\ [21/25] Installing simple-get@^3.0.3 [npminstall:runscript:error] vue-qr@3.2.4 › canvas@2.9 run install node-pre-gyp install --fallback-to-build --update-binary error: Error: Command failed with exit code 7: node-pre-gyp install --fallback-to-build --update-binary at makeError (E:\idea\node\node_global\node_modules\cnpm\node_modules\execa\lib\error.js:60:11) at handlePromise (E:\idea\node\node_global\node_modules\cnpm\node_modules\execa\index.js:118:26) at process.processTicksAndRejections (node:internal/process/task_queues:105:5) at async exports.runScript (E:\idea\node\node_global\node_modules\cnpm\node_modules\npminstall\lib\utils.js:261:12) at async runLifecycleScripts (E:\idea\node\node_global\node_modules\cnpm\node_modules\npminstall\lib\lifecycle_scripts.js:66:7) at async _install (E:\idea\node\node_global\node_modules\cnpm\node_modules\npminstall\lib\install_package.js:321:5) at async install (E:\idea\node\node_global\node_modules\cnpm\node_modules\npminstall\lib\install_package.js:23:12) at async mapper (E:\idea\node\node_global\node_modules\cnpm\node_modules\npminstall\lib\install_package.js:270:9) { shortMessage: 'Command failed with exit code 7: node-pre-gyp install --fallback-to-build --update-binary', command: 'node-pre-gyp install --fallback-to-build --update-binary', escapedCommand: 'node-pre-gyp install --fallback-to-build --update-binary', exitCode: 7, signal: undefined, signalDescription: undefined, stdout: undefined, stderr: undefined, failed: true, timedOut: false, isCanceled: false, killed: false × Install fail! Error: run install error, please remove node_modules before retry! Command failed with exit code 7: node-pre-gyp install --fallback-to-build --update-binary Error: Command failed with exit code 7: node-pre-gyp install --fallback-to-build --update-binary at makeError (E:\idea\node\node_global\node_modules\cnpm\node_modules\execa\lib\error.js:60:11) at handlePromise (E:\idea\node\node_global\node_modules\cnpm\node_modules\execa\index.js:118:26) at process.processTicksAndRejections (node:internal/process/task_queues:105:5) at async exports.runScript (E:\idea\node\node_global\node_modules\cnpm\node_modules\npminstall\lib\utils.js:261:12) at async runLifecycleScripts (E:\idea\node\node_global\node_modules\cnpm\node_modules\npminstall\lib\lifecycle_scripts.js:66:7) at async _install (E:\idea\node\node_global\node_modules\cnpm\node_modules\npminstall\lib\install_package.js:321:5) at async install (E:\idea\node\node_global\node_modules\cnpm\node_modules\npminstall\lib\install_package.js:23:12) at async mapper (E:\idea\node\node_global\node_modules\cnpm\node_modules\npminstall\lib\install_package.js:270:9) npminstall version: 7.12.0 npminstall argv: E:\idea\node\node.exe E:\idea\node\node_global\node_modules\cnpm\node_modules\npminstall\bin\install.js --fix-bug-versions --china --userconfig=C:\Users\刘雨晨\.cnpmrc --disturl=https://cdn.npmmirror.com/binaries/node --registry=https://registry.npmmirror.com
04-01
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值