Did you know LQ has a Linux Hardware Compatibility List?
Go Back > Forums > Linux Forums > Linux - General
User Name
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.


  Search this Thread
Old 05-08-2002, 06:49 AM   #1
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, 06:53 AM   #2
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


Old 05-08-2002, 07:25 AM   #3
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, 07:46 AM   #4
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, 09:24 AM   #5
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, 01:22 PM   #6
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, 10:59 AM   #7
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, 08:47 PM   #8
Registered: Feb 2004
Location: SE Tennessee, USA
Distribution: Gentoo, LFS
Posts: 5,728

Rep: Reputation: 1299Reputation: 1299Reputation: 1299Reputation: 1299Reputation: 1299Reputation: 1299Reputation: 1299Reputation: 1299Reputation: 1299
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, 10:00 PM   #9
Senior Member
Registered: Dec 2003
Posts: 3,161
Blog Entries: 4

Rep: Reputation: 135Reputation: 135
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.


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 03:05 PM
Compiling a module/Kernel mismatch fbarre Linux - Newbie 2 09-04-2003 08:26 PM
compiling a kernel module for a different target akaBeaVis Linux - Software 10 06-09-2003 12:47 AM
Kernel compiling and module compiling tarballed Linux - General 1 12-22-2002 05:31 PM
Is compiling/recompiling the kernel SOP? bxb32001 Linux - General 9 06-25-2001 03:38 AM

All times are GMT -5. The time now is 08:44 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration