LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Guide needed in device driver / module compilation. (https://www.linuxquestions.org/questions/linux-newbie-8/guide-needed-in-device-driver-module-compilation-588382/)

SPo2 09-30-2007 08:58 AM

Guide needed in device driver / module compilation.
 
Hi;

i am learning device driver / module coding for linux,
after browsing some web page, i get a test code below;

i faced an error while i try compile it in my
Mandriva 2006 KDE terminal using $ gcc <filename>


#include <linux/module.h>

int init_module(void)
{
printk("test test");
return 0;
}

void cleanup_module(void)
{
printk("------");
}


& i get these messages etc

In file included from /usr/include/linux/sched.h:11,
from /usr/include/linux/module.h:9,
from d.c:2:
/usr/include/linux/jiffies.h:84: error: syntax error before 'jiffies_64'
/usr/include/linux/jiffies.h:88: error: syntax error before 'get_jiffies_64'
/usr/include/linux/jiffies.h: In function 'timespec_to_jiffies':
/usr/include/linux/jiffies.h:320: error: called object 'u64' is not a function
/usr/include/linux/jiffies.h:320: error: called object 'u64' is not a function
/usr/include/linux/jiffies.h:320: error: 'NSEC_PER_SEC' undeclared (first use in
this function)
/usr/include/linux/jiffies.h:320: error: (Each undeclared identifier is reported
only once

blah blah.....



Is it that i have to place a kernel source in /usr/src/linux or the path where the package will auto unpack itself in?

If so, say if i'm using kernel 2.6.10, do i have to unpack a same kernel version or i can use a newer version?


Any Advise is helpful.
thanks

osor 09-30-2007 12:18 PM

Quote:

Originally Posted by SPo2 (Post 2908273)
i faced an error while i try compile it in my
Mandriva 2006 KDE terminal using $ gcc <filename>

You canít just compile like that. My recommendation is to use a Makefile that utilizes the kernel build system (on which there are plenty previous posts).


All times are GMT -5. The time now is 10:00 AM.