You are not logged in.

#1 2019-03-24 12:00:01

archdom
Member
Registered: 2018-09-12
Posts: 96

[SOLVED] Compile Simple module

Hi guys,

i'll want compile a simple module in Arch but i get the following error:

/home/.../..../Modulo//Modulo.c:1:10: fatal error:  linux/init.h : File o directory non esistente
#include < linux/init.h >
          ^~~~~~~~~~~~~~~~
compilation terminated.


I've already installed linux-headers package. This is my module:

#include < linux/init.h > 
#include < linux/module.h > 

MODULE_LICENSE("Dual BSD/GPL"); 

static int hello_init(void) {
    printk(KERN_ALERT "Hello, world\n"); 
    return 0; 
}

static void hello_exit(void) {
    printk(KERN_ALERT "Goodbye, cruel world\n"); 
}

module_init(hello_init); 
module_exit(hello_exit); 

This is the Makefile:

obj-m := Modulo.o

KDIR := /lib/modules/$(shell uname -r)/build

all:
    make -C $(KDIR) M=$(PWD) modules
clean:
    make -C $(KDIR) M=$(PWD) clean

In other distributions work as well
Who helps me? Thanks all

Last edited by archdom (2019-03-24 14:25:22)

Offline

#2 2019-03-24 12:36:31

graysky
Wiki Maintainer
From: :wq
Registered: 2008-12-01
Posts: 10,597
Website

Re: [SOLVED] Compile Simple module


CPU-optimized Linux-ck packages @ Repo-ck  • AUR packagesZsh and other configs

Offline

#3 2019-03-24 12:53:44

seth
Member
Registered: 2012-09-03
Posts: 51,312

Offline

#4 2019-03-24 14:01:47

archdom
Member
Registered: 2018-09-12
Posts: 96

Re: [SOLVED] Compile Simple module

i've already installed....but not works!

Offline

#5 2019-03-24 14:08:08

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 29,534
Website

Re: [SOLVED] Compile Simple module

Get rid of the spaces between the angled brackets and the file names.


"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" -  Richard Stallman

Offline

#6 2019-03-24 14:22:05

archdom
Member
Registered: 2018-09-12
Posts: 96

Re: [SOLVED] Compile Simple module

Trilby wrote:

Get rid of the spaces between the angled brackets and the file names.

it works!
how did I not think about it .... I'm really sorry.
thanks a lot

Last edited by archdom (2019-03-24 14:25:56)

Offline

#7 2019-03-24 14:44:20

seth
Member
Registered: 2012-09-03
Posts: 51,312

Re: [SOLVED] Compile Simple module

Which is btw. the reason for https://wiki.archlinux.org/index.php/Co … s_and_code (ok, at least one of them)

There's also a sub-zero chance for "In other distributions work as well" …

Offline

#8 2019-03-26 09:10:08

archdom
Member
Registered: 2018-09-12
Posts: 96

Re: [SOLVED] Compile Simple module

seth wrote:

There's also a sub-zero chance for "In other distributions work as well" …

I did copy and paste from Ubuntu .... and it worked there too. The problem is that during this procedure the editor has created some empty spaces that made the compilation fail. I didn't think it was sensitive to empty spaces .... I come from other programming languages.

Offline

Board footer

Powered by FluxBB