LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
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 01-17-2009, 02:50 PM   #1
sulacco
Member
 
Registered: Apr 2006
Posts: 46

Rep: Reputation: 15
Module isn't compiling


Hi, ppl. I'm trying to compile a driver which is
in /usr/src/linux/driver. I'm doing it like this:


HERE ADVICE FRO THE BOOK:
To compile a kernel driver as a module, toggle the corresponding menu choice button to <M> while configuring the kernel. Most of the device driver examples in this book are implemented as kernel modules. To build a module mymodule.ko from its source file mymodule.c, create a one-line Makefile and execute it as follows:
Code:
bash> cd /usr/src/linux/drivers/usb/class
bash> echo "obj-m += mymodule.ko" > Makefile
bash> make –C /usr/src/linux/drivers/usb/class/ M=`pwd` modules
but I get error like this:
Code:
make: Entering directory /usr/src/linux-2.6.28/drivers/usb/class
make: *** No rule to make target `modules`. Stop.
What's wrong? How compile a module from source code?
 
Old 01-18-2009, 12:18 PM   #2
ta0kira
Senior Member
 
Registered: Sep 2004
Distribution: FreeBSD 9.1, Kubuntu 12.10
Posts: 3,078

Rep: Reputation: Disabled
I think you need to -C to the top of the source tree; /usr/src/linux.
ta0kira

PS Why is your module in the source tree itself?
 
Old 01-18-2009, 02:15 PM   #3
sulacco
Member
 
Registered: Apr 2006
Posts: 46

Original Poster
Rep: Reputation: 15
Quote:
Originally Posted by ta0kira View Post
I think you need to -C to the top of the source tree; /usr/src/linux.
ta0kira

PS Why is your module in the source tree itself?
Ok, I have copied directory with sources to /home/mydir
and compiled it there. With some shell script.
 
Old 01-18-2009, 03:12 PM   #4
Drakeo
Senior Member
 
Registered: Jan 2008
Location: Urbana IL
Distribution: Slackware, Slacko,
Posts: 3,716
Blog Entries: 3

Rep: Reputation: 483Reputation: 483Reputation: 483Reputation: 483Reputation: 483
Quote:
Originally Posted by ta0kira View Post
I think you need to -C to the top of the source tree; /usr/src/linux.
ta0kira

PS Why is your module in the source tree itself?
you may want to look at the serious change in the 2.6.28 before you compile and begin to use it. 2.6.28 has moved the headers.from /include/asm to /arch/x86/include/asm so after you build it just get ready to work on thing if you are going X86_64 then things can work out a little better.
 
  


Reply



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
Compiling a module separately without compiling entire kernel kushalkoolwal Linux - Kernel 8 08-06-2008 01:45 AM
Invalid module error after compiling Acronis module cryogenica Linux - General 2 03-17-2008 04:23 PM
compiling a module eltn Programming 5 04-01-2006 07:30 PM
Use of MODULE macro while compiling a module fssengg Linux - Newbie 0 03-31-2006 07:13 AM
Kernel compiling and module compiling tarballed Linux - General 1 12-22-2002 05:31 PM

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

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