LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 02-27-2007, 09:29 AM   #1
Petros Koutoupis
LQ Newbie
 
Registered: Sep 2006
Posts: 4

Rep: Reputation: 0
asynchronous I/O for Linux 2.6 problems....


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.
 
Old 02-27-2007, 03:17 PM   #2
jim mcnamara
Member
 
Registered: May 2002
Posts: 964

Rep: Reputation: 36
gcc -lrt -Wall -o myaio myaio.c
 
Old 02-27-2007, 03:57 PM   #3
Petros Koutoupis
LQ Newbie
 
Registered: Sep 2006
Posts: 4

Original Poster
Rep: Reputation: 0
Thanks, cleanly compiles/links. I never thought about invoking gcc with the recommended switches.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
LXer: Linux: Syslets, Generic Asynchronous System Call Support LXer Syndicated Linux News 0 02-15-2007 10:16 PM
Asynchronous file I/O BradDaBug Programming 5 03-19-2006 05:11 PM
Programming asynchronous I/O in Linux with C iuaui Programming 2 09-30-2005 05:01 PM
Problem with asynchronous notification rajesh_b Programming 2 09-17-2004 07:58 AM
Synchronous vs Asynchronous Transfers WeNdeL Linux - Hardware 0 10-22-2003 03:34 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 04:52 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration