LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices



Reply
 
Search this Thread
Old 05-08-2002, 07:49 AM   #1
l_9_l
Member
 
Registered: Dec 2001
Location: New Zealand,Auckland
Distribution: debian
Posts: 86

Rep: Reputation: 15
compiling only one module without recompiling the kernel


Hi guys..

want to compile some driver as a module without recompiling the kernel,do you know how?
without make modules && make moudles_install

directly by using gcc,how?
 
Old 05-08-2002, 07:53 AM   #2
vfs
Member
 
Registered: Apr 2002
Location: Brazil
Distribution: Slackware
Posts: 184

Rep: Reputation: 30
You just need to tell gcc you want object code.

I can't remember which option it's but 'man gcc' surely can do

You type something like this:

gcc [options] module.c

HTH,

vfs.
 
Old 05-08-2002, 08:25 AM   #3
Mik
Senior Member
 
Registered: Dec 2001
Location: The Netherlands
Distribution: Ubuntu
Posts: 1,316

Rep: Reputation: 46
For a kernel module usually you would do something like this:

Compile it:
gcc -DMODULE -D__KERNEL__ -O6 -c module.c

Then you can test it with:
insmod module.o

If everything works fine then install it:
install -m 644 module.o /lib/modules/`uname -r`/destdir

Change the module.c and module.o to the name of the module. The destdir is the directory you want to install it in.
 
Old 05-08-2002, 08:46 AM   #4
theguide
LQ Newbie
 
Registered: Apr 2002
Location: Utrecht, Netherlands
Distribution: Slackware
Posts: 16

Rep: Reputation: 0
I'm not sure, but i believe i've read somewhere that you don't have to recompile the whole kernel when you want to compile a module.
Just run make menuconfig (or whatever is your choice of configuring the kernel), select the module you want to compile. Save the kernel options, make dep and make modules && make modules_install. The kernel will not be compiled, only the modules will.

But then again.. I might be wrong

And so that I can learn something too:
IF I'm wrong, please tell me!
 
Old 05-08-2002, 10:24 AM   #5
Mik
Senior Member
 
Registered: Dec 2001
Location: The Netherlands
Distribution: Ubuntu
Posts: 1,316

Rep: Reputation: 46
That would work if you have previously compiled your kernel in the same source tree. If you haven't or if you have done a make clean. Then all the modules will be recompiled not just one specific module.
 
Old 05-09-2002, 02:22 PM   #6
theguide
LQ Newbie
 
Registered: Apr 2002
Location: Utrecht, Netherlands
Distribution: Slackware
Posts: 16

Rep: Reputation: 0
Okay, that makes sence. But compiling the modules doesn't take that long unless you have a slow system of course.
I think figuring out how to compile the source of just one module takes longer than compiling all the modules
 
Old 07-06-2009, 11:59 AM   #7
himanshu.renegade
LQ Newbie
 
Registered: Jul 2009
Location: Delhi, India
Distribution: Ubuntu 8.10, RHEL
Posts: 3

Rep: Reputation: 0
i tried make modules and make modules_install
it does make the first module as the new module, but then alas it continues with all of the modules...

By the way, i want to compile and insert isicom.c module
 
Old 07-06-2009, 09:47 PM   #8
sundialsvcs
Guru
 
Registered: Feb 2004
Location: SE Tennessee, USA
Distribution: Gentoo, LFS
Posts: 5,455

Rep: Reputation: 1172Reputation: 1172Reputation: 1172Reputation: 1172Reputation: 1172Reputation: 1172Reputation: 1172Reputation: 1172Reputation: 1172
You should always make your kernel, each time you change any module, and thus allow "make" to figure it all out.

Each module will become "part of the kernel, in every respect," as soon as you install it. Therefore it is imperative that it exactly matches the rest of the installed kernel. There is "a correct way to do it," and you should religiously follow it. Don't try to shortcut.
 
Old 07-06-2009, 11:00 PM   #9
vharishankar
Senior Member
 
Registered: Dec 2003
Posts: 3,142
Blog Entries: 4

Rep: Reputation: 121Reputation: 121
Yes, allow the makefile to determine module dependencies. Sometimes compiling a single module might need to recompile other parts of your kernel, so never invoke gcc directly on the kernel source tree.
 
  


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 On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
can i compile just one kernel module whithout recompiling the whole kernel? edman007 Linux - Software 3 02-17-2004 04:05 PM
Compiling a module/Kernel mismatch fbarre Linux - Newbie 2 09-04-2003 09:26 PM
compiling a kernel module for a different target akaBeaVis Linux - Software 10 06-09-2003 01:47 AM
Kernel compiling and module compiling tarballed Linux - General 1 12-22-2002 06:31 PM
Is compiling/recompiling the kernel SOP? bxb32001 Linux - General 9 06-25-2001 04:38 AM


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