LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
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 10-18-2003, 03:25 AM   #1
oskernel
LQ Newbie
 
Registered: Sep 2003
Location: China
Posts: 25

Rep: Reputation: 15
How to write a kernel module(kernel object, .ko) on linux-2.6.0?


here is an example, anything wrong ?

//---------hello.c----------------
#include <linux/kernel.h>
#include <linux/module.h>
int init_module(void)
{
printk("hello world\n");
return 0;
}
void cleanup_module(void)
{
printk("bye\n");
}
//------end of hello.c-------

I compiled it with command:
gcc -I/usr/src/linux-2.6.0-test7/include -D_KERNEL_ -DMODULE -DKBUILD_MODNAME=hello -c hello.c
ant then I got may "undeclared" errors.

This is the first time for me to write kernel module on 2.6, and I even don't know how to generate a .ko file.
 
Old 10-21-2003, 02:20 PM   #2
ToniT
Senior Member
 
Registered: Oct 2003
Location: Zurich, Switzerland
Distribution: Debian/unstable
Posts: 1,357

Rep: Reputation: 47
Disclaimer: I don't know about 2.6 kernel internals.

If they mostly work as 2.4, one of the flags should be '-D__KERNEL__'

Also I would recommend the Linux device drivers book (still on 2.4, but should be applicaple to 2.6 in some extent).
 
  


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
[Error] Kernel Module : No kernel module build environment saman007uk Debian 7 09-09-2006 06:34 PM
Linux kernel debugging and Linux kernel module programming Igor007 Programming 2 08-13-2005 05:12 AM
Linux kernel debugging and Linux kernel module programming Igor007 Linux - Enterprise 3 08-12-2005 02:47 PM
Compiling kernel module for linux kernel 2.4 in 2.6 guam Linux - Software 0 01-13-2005 02:02 AM
How to write a kernel module(kernel object, .ko) on linux-2.6.0? oskernel Linux - Software 2 10-18-2003 06:04 AM

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

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