LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 04-23-2008, 07:36 AM   #1
mario-vallejo
LQ Newbie
 
Registered: Apr 2008
Location: Guadalajara Mexico
Distribution: Ubuntu 7.04
Posts: 1

Rep: Reputation: 0
Talking RTAI - Can't compile simple.c with gcc (hello world program)


Hello community,

I'm absolutely new to RTAI. I have succesfully installed Ubuntu 7.04 on a Pentium 3

PC.

I have successfully installed RTAI 3.5-Cv with 2.6.20 kernel but I can't compile the classic "Hello World" program.

I created simple.c under directory: /home/mario/hellow

The C code is:

/* simple.c */

#define __KERNEL__
#define MODULE
#include <linux/kernel.h>
#include <linux/module.h>

int init_module(void)
{
printk("hello, world!\n"); /* printk = kernel printf, to the console */

return 0;
}

void cleanup_module(void)
{
printk("goodbye, world!\n");

return;
}

/* end of simple.c */



When I compile with:

gcc -c simple.c

I receive error message:

simple.c:6:26: error: linux/module.h
Obviously compiler is not finding the header file module.h under "linux", since this

is a relative path i did the following:


I created subdirectory "linux" under /home/mario/hellow and copied into there all *.h

files that I found under /usr/src/linux-headers-2.6.20-15/include/linux.

I tried again gcc -c simple.c being my current directory /home/mario/hellow and still

same problem despite the fact that the directory linux with all header files exists

below.

Obviously I am not understanding on what directory I should create the simple.c code.

Can somebody please help?

Thank you so much!

Mario Vallejo
 
Old 04-23-2008, 08:13 AM   #2
Simon Bridge
LQ Guru
 
Registered: Oct 2003
Location: Waiheke NZ
Distribution: Ubuntu
Posts: 9,211

Rep: Reputation: 198Reputation: 198
You need a tutorial:
http://www.isd.mel.nist.gov/projects...c/tutorial.htm

why not
#include <kernel.h>
#include <module.h>

... and let the environment variables point to the linux headers? Is module.h even in there?
 
  


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 On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
trying to compile simple inotify C program xaos5 Programming 5 12-20-2007 09:01 PM
can't compile simple C++ programs on Suse 9.1 after installing gcc cyclebain Linux - Software 9 07-04-2007 08:04 AM
Can't compile c++ program using gcc pengu Programming 9 02-22-2006 01:59 PM
Trouble Compiling a simple Hellow World on Solaris 9 with GCC 3.4.2 jitendra64 Solaris / OpenSolaris 4 10-11-2004 02:57 PM
Why doesn't this simple program compile? SparceMatrix Programming 4 08-27-2002 03:37 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 01:19 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