LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > General
User Name
Password
General This forum is for non-technical general discussion which can include both Linux and non-Linux topics. Have fun!

Notices


Reply
  Search this Thread
Old 03-04-2024, 12:34 PM   #1
slcklnx
Member
 
Registered: Jan 2019
Posts: 144

Rep: Reputation: Disabled
building the linux kernel module


there is a
Code:
kernel_module.c
file

there is a directory
Code:
/usr/local/bin/MMD
with copied kernel headers

does someone have the knowledge to tell which gcc commands to run to build a kernel module without scripts and make utilities?
 
Old 03-04-2024, 01:00 PM   #2
smallpond
Senior Member
 
Registered: Feb 2011
Location: Massachusetts, USA
Distribution: Fedora
Posts: 4,135

Rep: Reputation: 1262Reputation: 1262Reputation: 1262Reputation: 1262Reputation: 1262Reputation: 1262Reputation: 1262Reputation: 1262Reputation: 1262
It is unlikely that you will find this knowledge since no-one builds kernel modules this way. It may be possible, but typing 100-character command lines manually seems pointless.

If you want to do it, the simplest way is to run the standard Makefile command to build a module and then copy what it does:

Code:
make -C <path_to_kernel_src> M=$PWD
 
Old 03-04-2024, 01:26 PM   #3
slcklnx
Member
 
Registered: Jan 2019
Posts: 144

Original Poster
Rep: Reputation: Disabled
only with gcc without make. you can tell exactly where the scripts for building the module are located. perhaps I would have seen the necessary commands in them.
 
Old 03-04-2024, 04:24 PM   #4
smallpond
Senior Member
 
Registered: Feb 2011
Location: Massachusetts, USA
Distribution: Fedora
Posts: 4,135

Rep: Reputation: 1262Reputation: 1262Reputation: 1262Reputation: 1262Reputation: 1262Reputation: 1262Reputation: 1262Reputation: 1262Reputation: 1262
The module build process is described here: https://elixir.bootlin.com/linux/lat...ld/modules.rst
 
Old 03-04-2024, 07:47 PM   #5
sundialsvcs
LQ Guru
 
Registered: Feb 2004
Location: SE Tennessee, USA
Distribution: Gentoo, LFS
Posts: 10,629
Blog Entries: 4

Rep: Reputation: 3930Reputation: 3930Reputation: 3930Reputation: 3930Reputation: 3930Reputation: 3930Reputation: 3930Reputation: 3930Reputation: 3930Reputation: 3930Reputation: 3930
The very best way to approach this is to simply view the "kernel source and header directories" as a source of information. Not that you will then attempt to use them to "build a kernel for yourself." Because the distributors of "your favorite distro" know far more about this process than you do.
 
Old 03-06-2024, 12:27 AM   #6
slcklnx
Member
 
Registered: Jan 2019
Posts: 144

Original Poster
Rep: Reputation: Disabled

where can I see the module build scripts? I didn't say that I know Linux. I've always said I'm new to this. please tell me specifically where is the script with the gcc command set for building the kernel module?
 
Old 03-06-2024, 07:04 AM   #7
_blackhole_
Member
 
Registered: Mar 2023
Distribution: FreeBSD
Posts: 87

Rep: Reputation: 66
You seem to be providing the least information possible, while fishing for a quick solution to whatever it is you're trying to do...

You also appear to have a history of this.

Have a look here and work it out for yourself (example): https://tldp.org/LDP/lkmpg/2.4/html/lkmpg.html#AEN208

If you choose not to use a makefile, that's your decision to pursue something more advanced, therefore you are expected to do the reseatch.
 
Old 03-06-2024, 07:38 AM   #8
smallpond
Senior Member
 
Registered: Feb 2011
Location: Massachusetts, USA
Distribution: Fedora
Posts: 4,135

Rep: Reputation: 1262Reputation: 1262Reputation: 1262Reputation: 1262Reputation: 1262Reputation: 1262Reputation: 1262Reputation: 1262Reputation: 1262
The file Makefile in the root directory of the kernel source is what builds the kernel and module. There is no script with a gcc command in it.
 
Old 03-06-2024, 05:59 PM   #9
dugan
LQ Guru
 
Registered: Nov 2003
Location: Canada
Distribution: distro hopper
Posts: 11,215

Rep: Reputation: 5309Reputation: 5309Reputation: 5309Reputation: 5309Reputation: 5309Reputation: 5309Reputation: 5309Reputation: 5309Reputation: 5309Reputation: 5309Reputation: 5309
Obviously, you solve this by installing make. Or by copying /usr/bin/MMD to a computer that has it. Don't tell me you can't do either one, because that response would be silly. And don't say that that's not what you asked, because that would be even more silly.

Quote:
Originally Posted by slcklnx View Post
where can I see the module build scripts? I didn't say that I know Linux. I've always said I'm new to this. please tell me specifically where is the script with the gcc command set for building the kernel module?
That's... actually what the Makefiles are.

Last edited by dugan; 03-06-2024 at 06:19 PM.
 
  


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
Error building linux kernel module (Invalid module format) cspy Linux - Kernel 2 02-09-2022 07:26 AM
Linux kernel module installation and other questions related to kernel module install yashgovin19 Linux - Newbie 1 06-03-2015 02:33 PM
Building an out-of-tree module without building the kernel source lijodevasia Linux - General 2 08-01-2013 12:45 AM
Building kernel module from multiple source file in 2.6 kernel yogeshwar_s Programming 1 12-20-2004 09:31 AM
Problems building a simple kernel module for kernel 2.6.7 atticman Linux - Software 2 12-13-2004 03:35 PM

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

All times are GMT -5. The time now is 02:31 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