关于linux里面的异步io的问题,请各位给点提示,谢谢

leolyq 2006-10-28 09:50:07
正在自学linux下编程,看到aio部分就想编个程序实验一下,但是却遇到了问题如下:

包含了 头文件 aio.h
但是编译的时候会有如下错误提示:
myaio.o: In function `main':/home/aki/kdevelop/myaio/src/myaio.c:24: undefined reference to `aio_read'
myaio.o: In function `on_input':/home/aki/kdevelop/myaio/src/myaio.c:34: undefined reference to `aio_error'
:/home/aki/kdevelop/myaio/src/myaio.c:36: undefined reference to `aio_return'
:/home/aki/kdevelop/myaio/src/myaio.c:42: undefined reference to `aio_read'

小弟是新来的,刚刚接触linux编程,还不是很熟悉,请高手一定要指导一下哦!!
附上我的源码:

#include <aio.h>
#include <stdio.h>
#include <signal.h>

struct aiocb kbcbuf;
int done;

void on_input(int);
void setup_aio_buffer();

main()
{

done=0;
signal(SIGIO, on_input);
setup_aio_buffer();
aio_read(&kbcbuf);
while(done!=1)
pause();
}

void on_input(int signum)
{
int c;
char* cp=(char*)kbcbuf.aio_buf;

if(aio_error(&kbcbuf)!=0)
perror("Reading failed");
else if(aio_return(&kbcbuf)==1)
c=*cp;
if(c=='q'||c==EOF)
done=1;
else printf("%c", c);

aio_read(&kbcbuf);
}

void setup_aio_buffer()
{
static char input[1];
kbcbuf.aio_fildes=0;
kbcbuf.aio_buf=input;
kbcbuf.aio_nbytes=1;
kbcbuf.aio_offset=0;
kbcbuf.aio_sigevent.sigev_notify=SIGEV_SIGNAL;
kbcbuf.aio_sigevent.sigev_signo=SIGIO;
}

...全文
194 8 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
leolyq 2006-10-28
  • 打赏
  • 举报
回复
没人理我,好伤心
leolyq 2006-10-28
  • 打赏
  • 举报
回复
高手快快来~~~
leolyq 2006-10-28
  • 打赏
  • 举报
回复
请问一下库文件是哪个阿?
Andrionda 2006-10-28
  • 打赏
  • 举报
回复
你没有指定aio库文件的路径.
执行的时候你指定一下路径,或者将其放在make文件里.
leolyq 2006-10-28
  • 打赏
  • 举报
回复
顶一下!!!
Andrionda 2006-10-28
  • 打赏
  • 举报
回复
查找<aio.h> 的路径
Andrionda 2006-10-28
  • 打赏
  • 举报
回复
比如:
g++ -o Server main.o Server.o -L/opt/ACE/lib
你根据自己的路径来编译.
Andrionda 2006-10-28
  • 打赏
  • 举报
回复
我不知道你的aio的文件在哪里.
但是一般的都在 /usr/include/lib下

23,217

社区成员

发帖
与我相关
我的任务
社区描述
Linux/Unix社区 应用程序开发区
社区管理员
  • 应用程序开发区社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧