LinuxQuestions.org
Review your favorite Linux distribution.
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 12-05-2011, 12:27 AM   #1
Pouyaaa
LQ Newbie
 
Registered: Dec 2011
Posts: 4

Rep: Reputation: Disabled
Problem with compiling the module driver


I'm newbie at driver module programming.... I've written a very simple hello world module then I wanna compile it , I got this result :
Code:
make -C /lib/modules/2.6.38-8-generic/build M=/root/ker modules
make[1]: Entering directory `/usr/src/linux-headers-2.6.38-8-generic'
make[1]: Makefile: No such file or directory
make[1]: *** No rule to make target `Makefile'.  Stop.
make[1]: Leaving directory `/usr/src/linux-headers-2.6.38-8-generic'
make: *** [all] Error 2
Also I've installed linux headers via following command
Code:
apt-get install linux-headers-2.6.38-8-generic
here is my Makefile file
Code:
obj-m += hello.o

all:
        make -C /lib/modules/$(shell uname -r)/build M=$(shell pwd) modules

clean:
        make -C /lib/modules/$(shell uname -r)/build M=$(shell pwd) clean
Also I gotta note that , the "build" is not exist at that folder

my source code :

Code:
#include <linux/module.h>
#include <linux/kernel.h>
 
int init_module(void)
{
        printk(KERN_INFO "init_module() called\n");
        return 0;
}
 
void cleanup_module(void)
{
        printk(KERN_INFO "cleanup_module() called\n");
}
thanks
 
Old 12-05-2011, 02:47 AM   #2
Meson
Member
 
Registered: Oct 2007
Distribution: Arch x86_64
Posts: 606

Rep: Reputation: 67
Is Makefile in the linux src directory? You might need a different package for Ubuntu.
 
Old 12-05-2011, 02:59 AM   #3
Meson
Member
 
Registered: Oct 2007
Distribution: Arch x86_64
Posts: 606

Rep: Reputation: 67
Also, while we're at it. Your hello world should look more like this:

Code:
#include <linux/kernel.h>
#include <linux/module.h>

static int __init mymodule_init(void)
{
	printk(KERN_INFO "init_module() called\n");
	return 0;
}

static void __exit mymodule_exit(void)
{
	printk(KERN_INFO "cleanup_module() called\n");
}

module_init(mymodule_init);
module_exit(mymodule_exit);

MODULE_LICENSE("GPL");
MODULE_AUTHOR("me");
MODULE_DESCRIPTION("Hello, World!");
 
Old 12-05-2011, 04:35 AM   #4
Pouyaaa
LQ Newbie
 
Registered: Dec 2011
Posts: 4

Original Poster
Rep: Reputation: Disabled
Sorry man , I got the problem solved by removing all of the linux source headers and re-install the proper one.... so all the lnk links are correct now

yeah I got that hello world missing lines added

thanks
 
  


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
Help required in compiling Network driver module. ravi14 Linux - Software 1 10-19-2008 03:01 AM
invalid module when compiling RT25USB v2.0.8.0 driver from Ralink Basel Linux - Wireless Networking 3 07-21-2007 03:46 AM
Unable to load wacom driver module after compiling for a 2.6.14.4 kernel dr_zayus69 Linux - Kernel 1 06-28-2006 10:38 AM
compiling driver and installing module giraf Debian 9 06-06-2006 03:23 PM
problem compiling kernel module fbarsoba Linux - Software 2 04-20-2006 11:55 AM

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

All times are GMT -5. The time now is 03:11 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration