I have been trying to resolve this for a short while now and I am getting very frustrated. I have been attempting to write a simple program for asynchronous I/O, make sure it works and then eventually merge it into the main branch of our company's I/O utility. Here is the source:
Code:
#define _USE_GNU
#define _GNU_SOURCE
#define _XOPEN_SOURCE 600
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <aio.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
int main(int argc, char *argv[])
{
int status;
struct aiocb myaio;
myaio.aio_fildes = open(argv[1], O_RDONLY | O_DIRECT);
if(myaio.aio_fildes == -1)
{
perror("open");
exit(0);
}
myaio.aio_nbytes = 512;
myaio.aio_offset = 0;
posix_memalign((void *)&myaio.aio_buf, 512, 512);
status = aio_read(&myaio);
//rest of code is irrelevant, it cannot seem to properly input
//the reference of myaio into aio functions such as aio_read/aio_write
return 0;
}
Here is the error I get during the compilation/linking process:
Code:
/tmp/ccAtflgo.o(.text+0x8f): In function `main':
: undefined reference to `aio_read'
collect2: ld returned 1 exit status
I have even looked at aio examples off of the net to find that they are exactly like mine and error out exactly like mine. I am working with linux kernels 2.6.9-x and 2.6.16-x. Are there any known problems with aio or what am I doing wrong? Thanks in advance.