gpt4 book ai didi

c++ - linux C++ : libaio. h 不包含 io_context _t 的定义?

转载 作者:太空宇宙 更新时间:2023-11-04 09:20:21 29 4
gpt4 key购买 nike

我有一个 super 简单的 .cpp 文件,如下所示:

    $cat test001.cpp
#include<libaio.h>
int main(){
io_context_t ctx={0};
struct iocb io,*p=&io;
return 0;
}

但是用gcc 4.1.2编译后,提示错误:

    $g++ test001.cpp -laio
test001.cpp:1:19: error: libaio.h: No such file or directory
test001.cpp: In function ‘int main()’:
test001.cpp:3: error: ‘io_context_t’ was not declared in this scope
test001.cpp:3: error: expected `;' before ‘ctx’
test001.cpp:4: error: aggregate ‘iocb io’ has incomplete type and cannot be defined

我已经在使用“libaio.h”了。为什么还是失败?

最佳答案

sudo apt-get install libaio-dev 它肯定能解决这个问题。它是用于Linux 内核AIO 访问库-开发文件。

关于c++ - linux C++ : libaio. h 不包含 io_context _t 的定义?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42641908/

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