LinuxQuestions.org
Register a domain and help support LQ
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 08-29-2007, 11:18 PM   #1
vrishankaryan
LQ Newbie
 
Registered: Aug 2007
Posts: 7

Rep: Reputation: 0
Hello World Module not working


Hi all
I wrote a Hello World module . Does n't seem to work - compiles but i cant insmod the same.
The program is #define MODULE
#include <linux/version.h>
#include <linux/init.h>
#include <linux/module.h>

MODULE_LICENSE("Dual BSD/GPL");

static int hello_init(void)
{
printk("Hello World!");
return 0;
}

static void hello_exit(void)
{
printk("Good Bye");

}

module_init(hello_init);
module_exit(hello_exit);



Now this is the way i compile it

#gcc -c hello.c
#insmod hello.o
This isthe error i get

hello.o : kernel - module version mismatch.
hello.o was compiled for kernel version 2.4.20
while this kernel is version 2.4.22-1.2115.ntpl

Another question , how to use KERN_ALERT in printk? What should the include file be?

And finally , what is .ko for example xyz.ko . How is it different from xyz.o??
Please help
 
Old 08-30-2007, 10:14 PM   #2
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.8, Centos 5.10
Posts: 17,260

Rep: Reputation: 2328Reputation: 2328Reputation: 2328Reputation: 2328Reputation: 2328Reputation: 2328Reputation: 2328Reputation: 2328Reputation: 2328Reputation: 2328Reputation: 2328
Maybe this will help: http://www.linuxhq.com/lkprogram.html
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
how to insert a hello world module into kernel dinesh_t Ubuntu 2 03-31-2007 04:08 AM
building a hello world module sancho1980 Linux - Kernel 0 09-29-2006 09:29 PM
problems with Hello World kernel2.6 module Ralc Programming 0 03-10-2006 05:59 PM
hello world module the_uplink2x Programming 19 04-12-2005 03:14 PM
hello world module aliyildiz Linux - General 1 12-09-2001 06:04 AM


All times are GMT -5. The time now is 11:03 AM.

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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration