By finding where the init.h is I found several locations and specified in makefile the best one that seems to be. Now I am getting build error below.
Since logs are massive (444000 chars), it will not fit here so I put the last section of the log generated from build:
Paths I discovered for init.h and linkage.h
Code: Select all
// centos 72
///usr/src/kernels/3.10.0-327.el7.x86_64/arch/x86/include/asm/init.h
///usr/src/kernels/3.10.0-327.el7.x86_64/include/config/debug/memory/init.h
///usr/src/kernels/3.10.0-327.el7.x86_64/include/config/provide/ohci1394/dma/init.h
///usr/src/kernels/3.10.0-327.el7.x86_64/include/linux/init.h
///usr/src/kernels/3.10.0-327.el7.x86_64/arch/x86/include/asm/linkage.h
///usr/src/kernels/3.10.0-327.el7.x86_64/include/asm-generic/linkage.h
///usr/src/kernels/3.10.0-327.el7.x86_64/include/linux/linkage.h
///usr/src/kernels/3.10.0-327.el7.x86_64.debug/arch/x86/include/asm/linkage.h
///usr/src/kernels/3.10.0-327.el7.x86_64.debug/include/asm-generic/linkage.h
///usr/src/kernels/3.10.0-327.el7.x86_64.debug/include/linux/linkage.h
Code: Select all
CC=gcc
I1=/usr/src/kernels/3.10.0-327.el7.x86_64/arch/x86/include/
I2=/usr/src/kernels/3.10.0-327.el7.x86_64/include/
I3=/usr/src/kernels/2.6.32-754.10.1.el6.x86_64.debug/include/
CFLAGS=-O3 -I $(I1) -I $(I2)
hello: hello.c
$(CC) $(CFLAGS) hello.c
Code: Select all
#include <linux/init.h>
#include <linux/module.h>
MODULE_LICENSE("Dual BSD/GPL")
static int hello_init(void) {
// printk(KERN_ALERT "Hello, world.\n");
printk("Hello, world.\n");
return 0;
}
static void hello_exit(void) {
// printk(KERN_ALERT "Goodbye, cruel world.\n");
printk("Goodbye, cruel world.\n");
}
module_init(hello_init);
module_exit(hello_exit);
Code: Select all
=~=~=~=~=~=~=~=~=~=~=~= PuTTY log 2019.01.18 11:43:02 =~=~=~=~=~=~=~=~=~=~=~=
make hello1
gcc -O3 -I /usr/src/kernels/3.10.0-327.el7.x86_64/arch/x86/include/ -I /usr/src/kernels/3.10.0-327.el7.x86_64/include/ hello.c
In file included from hello.c:27:0:
/usr/src/kernels/3.10.0-327.el7.x86_64/include/linux/init.h:155:13: error: expected =, ,, ;, asm or __attribute__ before load_default_modules
void __init load_default_modules(void);
^
/usr/src/kernels/3.10.0-327.el7.x86_64/include/linux/init.h:255:13: error: expected =, ,, ;, asm or __attribute__ before parse_early_param
void __init parse_early_param(void);
^
...
...
...
static exitcall_t __exitcall_##fn __exit_call = fn
^
/usr/src/kernels/3.10.0-327.el7.x86_64/include/linux/init.h:279:24: note: in expansion of macro __exitcall
#define module_exit(x) __exitcall(x);
^
hello.c:44:1: note: in expansion of macro module_exit
module_exit(hello_exit);
^
hello.c:44:24: error: expected declaration specifiers before ; token
module_exit(hello_exit);
^
In file included from /usr/src/kernels/3.10.0-327.el7.x86_64/include/linux/cache.h:4:0,
from /usr/src/kernels/3.10.0-327.el7.x86_64/include/linux/time.h:4,
from /usr/src/kernels/3.10.0-327.el7.x86_64/include/linux/stat.h:18,
from /usr/src/kernels/3.10.0-327.el7.x86_64/include/linux/module.h:10,
from hello.c:28:
/usr/src/kernels/3.10.0-327.el7.x86_64/include/linux/kernel.h:255:6: error: old-style parameter declarations in prototyped function definition
void do_exit(long error_code)
^
hello.c:44:24: error: expected { at end of input
module_exit(hello_exit);
^
make: *** [hello1] Error 1
[root@dev-learn-rhel7 device-drivers]#