![]() |
ubuntu.com - launchpad.net - ubuntu help
|
|
|||||||
Ubuntu 9.10 is out!!!
When downloading Ubuntu 9.10 please consider using bittorrent to get your copy of Ubuntu. The Ubuntu Developers Summit for Lucid Lynx will be held the week of 16-Nov-2009 till 20-Nov-2009 in Dallas, TX USA. Visit the the Ubuntu wiki for more information about UDS and how to participate remotely. |
|
Programming Talk This forum is for all programming questions. The questions do not have to be directly related to Ubuntu and any programming language is allowed. |
|
|
Thread Tools | Display Modes |
|
|
#2 |
|
Quad Shot of Ubuntu
![]() Join Date: Jan 2006
Location: Grønland,Oslo
Beans: 482
|
Re: errors compiling modules
Hello,
Try this File:mod1.c Code:
/*
#define _LINUX_TIME_H 1
thats to solve the "Redefinition von »struct timespec«" problem
*/
#include <linux/version.h>
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/moduleparam.h>
#include <linux/time.h>
#include <linux/init.h>
#include <linux/stat.h>
MODULE_LICENSE("GPL");
MODULE_AUTHOR("Kalle & Olga Kuusamolainen");
static int __init init_this_module(void)
{
printk(KERN_INFO "mod1: init_this_module() called.\n");
return 0;
}
static void __exit shutdown_this_module(void)
{
printk(KERN_INFO "mod1: shutdown_this_module() called.\n");
}
module_init(init_this_module);
module_exit(shutdown_this_module);
Code:
obj-m := mod1.o KDIR := /lib/modules/$(shell uname -r)/build PWD := $(shell pwd) default: $(MAKE) -C $(KDIR) SUBDIRS=$(PWD) modules In the Makefile, there must be a TAB (tabulator) character before the $(MAKE) -C $(KDIR) SUBDIRS=$(PWD) modules line. Compile it (using the Makefile): $ make Load the module mod1.ko: $ sudo insmod mod1.ko Now check the system messages $ dmesg | tail -10 [13408.233936] mod1: init_this_module() called. Remove the module: $ sudo rmmod mod1 Check again the system messages $ dmesg | tail -10 or $ dmesg | grep "mod1" [13408.233936] mod1: init_this_module() called. [13408.233937] mod1: shutdown_this_module() called. Very important: Study these kernel developers' guides http://www.futuredesktop.org/kernel.html Section: Driver and module programming. Good luck ----------------------- EDIT: Prerequisites to compile a kernel-module are: $ sudo aptitude install build-essential gdb linux-headers-$(uname -r) You may also need: $ sudo aptitude install automake autoconf libtool ----------------------- ps. This is howto install VMware Player and VirtualBox in/on Ubuntu 7.10 beta (gutsy gibbon). http://www.futuredesktop.org/vmware/...yer-gutsy.html (just in case you need some love) Last edited by moma; December 19th, 2007 at 08:56 AM.. |
|
|
|
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|