Score:0

What are the current requirements for compiling a module in Ubutu LTS

cn flag

There are a few other similar questions that all end with

sudo apt-get install linux-headers-$(uname -r) build-essential

I am trying to follow this

https://devarea.com/linux-kernel-development-creating-a-proc-file-and-interfacing-with-user-space/#.YMTLWTqxVH5

Which has headers such as

#include <linux/module.h>
#include <linux/moduleparam.h>
#include <linux/init.h>
#include <linux/kernel.h>   
#include <linux/proc_fs.h>
#include <asm/uaccess.h>

no matter how I compile, the downloaded headers I get a chain of more missing deps.

e.g .

gcc -Wall -Werror  
-I/usr/src/linux-hwe-5.8-headers-5.8.0-55/include 
-I/usr/src/linux-hwe-5.8-headers-5.8.0-55/arch/x86/include/ 
-I/usr/src/linux-headers-5.8.0-55-generic/arch/x86/include/generated 
-I/usr/src/linux-headers-5.8.0-55-generic/include 
-I/usr/src/linux-hwe-5.8-headers-5.8.0-55/include/uapi 
-c hello.c

I feel like I'm missing something. Is there any Ubuntu dev guide for kernel modules that includes how to get the required source and tools to compile a simple hello world module in 20.04LTS.

chili555 avatar
cn flag
Is there any improvement if you do: `sudo apt install linux-headers-generic`?
hr flag
The post you linked looks like part 2 of a series - in the first part [Linux Kernel Development and Writing a Simple Kernel Module](https://devarea.com/linux-kernel-development-and-writing-a-simple-kernel-module/) the author shows how to do build the module - in particular, scroll down to *To build the module we need the following Makefile* - it's not just a matter of running `gcc` as you would for a userland C program
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.