Scientific Linux Forum.org



  Reply to this topicStart new topicStart Poll

> Kernel header pacakge
landonbgood
 Posted: Feb 24 2015, 10:54 PM
Quote Post


SLF Newbie


Group: Members
Posts: 2
Member No.: 3373
Joined: 24-February 15









Hi there,

I'm a brand new user to Linux. I have recently installed this onto a PC for school purposes. I have an assignment that requires me to have include/linux/init.h as well as include/linux/module.h. I don't have either of those and I have tried becoming a super user and using yum update kernel, yum install kernel-devel, yum install kernel-headers. I still have no luck with getting these mythical files. I thought maybe my kernel might have been updated but my pacakges weren't up to date so I checked and everything seems to be the same shown here:
rpm -qa kernel\* | sort
kernel-2.6.32-504.8.1.el6.x86_64
kernel-2.6.32-504.el6.x86_64
kernel-devel-2.6.32-504.8.1.el6.x86_64
kernel-firmware-2.6.32-504.8.1.el6.noarch
kernel-headers-2.6.32-504.8.1.el6.x86_64

Any help is greatly appreciated!

Side note I am currently installing devtoolset-2 (had devtoolset1-1), not sure if that has anything to do with this, I doubt it, but I thought the more information for you lovely people to help me with the better!

EDIT: Using SL6.6

-Landon
PMEmail Poster
^
burakkucat
 Posted: Feb 24 2015, 11:20 PM
Quote Post


SLF Administrator
****

Group: Admins
Posts: 193
Member No.: 14
Joined: 10-April 11









You do have those files but not where, I presume, that you were looking (the /usr/include/linux/ directory).

You will find that both files are provided by the kernel-devel package and are installed under the /usr/src/kernels/ directory . . .

[Build64R6 ~]$ find /usr/src/kernels/$(uname -r) -type f \( -name init.h -o -name module.h \) | grep linux
/usr/src/kernels/2.6.32-504.8.1.el6.x86_64/include/linux/init.h
/usr/src/kernels/2.6.32-504.8.1.el6.x86_64/include/linux/module.h
[Build64R6 ~]$


This post has been edited by burakkucat: Feb 24 2015, 11:21 PM

--------------------
user posted image 100% Linux and, previously, Unix. Co-founder of the ELRepo Project.
PMUsers Website
^
landonbgood
 Posted: Feb 25 2015, 12:31 AM
Quote Post


SLF Newbie


Group: Members
Posts: 2
Member No.: 3373
Joined: 24-February 15









You are a wizard! Great, so if its okay I have another question now that I know where the files are. I have a program made and I need to get it to run but I'm not sure where I'm supposed to put it. At the moment its on my Desktop and when I compile it I receive:
CODE
simple.c:1:24: fatal error: linux/init.h: No such file or directory
#include <linux/init.h>
                       ^
compilation terminated.


I figure I need to put this file somewhere else where it can get at that header file? If so how would I go about moving that file into where it needs to be?

EDIT: put the program into usr/src/kernels/2.6.32-504.8.1.el6.x86_64 via the cp command and attempted to run it using the makefile in the folder. However it did not work. The program prints a mesage when the module is loaded and unloaded. For headers it has
CODE

#include <linux/init.h>
#include <linux/kernel.h>
#include <linux/module.h>
PMEmail Poster
^
helikaon
 Posted: Feb 25 2015, 06:12 AM
Quote Post


SLF Administrator
*******

Group: Admins
Posts: 833
Member No.: 4
Joined: 8-April 11










hi there,
try google the error you're getting - i think here it is explained nicely :]

cheers :]

--------------------
PMEmail Poster
^
burakkucat
 Posted: Feb 25 2015, 03:10 PM
Quote Post


SLF Administrator
****

Group: Admins
Posts: 193
Member No.: 14
Joined: 10-April 11









Not knowing the assignment that Landon has been set or any other background, I'll just add a few basic comments.
CODE

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

Those three lines are directives to the C-preprocessor, whose first task is to expand the <linux/init.h>, for example, into /usr/include/linux/init.h (the usual place for ordinary userland C-code, indicated by the < . . . > pairing is defined as /usr/include/) and then in a later phase, it reads in the contents of the file so defined.

There is an alternative form of a #include line, such as --
CODE

#include "foo.h"

In this case, the C-preprocessor expands the "foo.h" as ./foo.h. In other words, the file to be included is in the current directory. As before, in a later phase, it reads in the contents of the file so defined.

Having got that "out of the way", the correct solution is mentioned in the link that Helikaon has provided. The source code file needs to be compiled within the context of the kernel sources. For SL, as with any clone of RHEL, the full kernel sources are not required. The files provided by the kernel-devel package are sufficient and a correct context can be obtained by using the /lib/modules/$(uname -r)/build/ directory. (Which, if insepcted, will be seen to be a symbolic link to the /usr/src/kernels/$(uname -r)/ directory.)

Hopefully the above (and the earlier posts) gives sufficient information to allow the assignment to be tackled . . . (I could write far more and illustrate it with further examples but then, I feel, I would be doing the assignment myself! wink.gif )

--------------------
user posted image 100% Linux and, previously, Unix. Co-founder of the ELRepo Project.
PMUsers Website
^
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

Topic Options Reply to this topicStart new topicStart Poll