Results 1 to 6 of 6

Thread: what's the use of linux-header-3.x.x?

  1. #1
    Join Date
    Dec 2013
    Beans
    5

    what's the use of linux-header-3.x.x?

    I am studying kernel programing these days,

    I am trying to play with syscall and it seems like i only change things in source directory,

    What's the use of header directory that i downloaded

  2. #2
    Join Date
    Jul 2007
    Location
    Magic City of the Plains
    Beans
    Hidden!
    Distro
    Xubuntu Development Release

    Re: what's the use of linux-header-3.x.x?

    Moved to Programming Talk.

  3. #3
    Join Date
    May 2007
    Location
    Leeds, UK
    Beans
    1,675
    Distro
    Ubuntu

    Re: what's the use of linux-header-3.x.x?

    Header files contain declarations (types, macros, functions, etc.) that are defined in source files. Other source files that want to make use of those declarations import the header files. The linker brings it all together.

    For example; if you have a module that provides a stack data structure, you might create a header file 'stack.h' that declares a function called 'pop'. The implementation of 'pop' goes in 'stack.c'. If you want to work with a stack in your main program, lets call it 'main.c', you '#include stack.h'. You can then use the 'pop' function because you have the declaration. The compiler compiles your main program as a standalone unit into an object (.o) file which has an unresolved reference to that 'pop' function.

    When you link your program to create main, the linker resolves all the symbols from all the .o files and creates the executable.

    The Linux kernel has lots of separate source files, so lots of header files.

    I didn't have time to read this link thoroughly but it looks like it covers what you need to know, with examples:

    http://www.icosaedro.it/c-modules.html
    Please create new threads for new questions.
    Please wrap code in code tags using the '#' button or enter it in your post like this: [code]...[/code].

  4. #4
    Join Date
    Nov 2005
    Location
    Sendai, Japan
    Beans
    11,296
    Distro
    Kubuntu

    Re: what's the use of linux-header-3.x.x?

    Quote Originally Posted by hadriansong View Post
    I am studying kernel programing these days,

    I am trying to play with syscall and it seems like i only change things in source directory,

    What's the use of header directory that i downloaded
    If by "header directory" you mean the linux-header packages, they are used to compile kernel-related code (kernel modules, most often) after the kernel has been compiled and installed. They are different from the kernel source, which is used to compile the kernel itself.
    「明後日の夕方には帰ってるからね。」


  5. #5
    Join Date
    Dec 2013
    Beans
    5

    Re: what's the use of linux-header-3.x.x?

    Linux-header packages are just simply header file that is used to complie kenrenl-related code. So, we don't use this package to complie kernel itself, right? whenever I change or add module (system call?) in Kernel source (such as hello world), it is compailed and installed only in source package, right? i just wanna make sure.

    Thank you,

  6. #6
    Join Date
    Dec 2013
    Beans
    5

    Re: what's the use of linux-header-3.x.x?

    Thank you. If you don't mind, I want to ask you another one. For module programming, I can just code something in user mode, right? not in the root mode.
    I want to clearfy what I know. There are user mode and root mode. In user mode, you can program some user -based application, but when you change to root mode, that means you are trying to change or install certain function in kernel. Am I understanding correctly?

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •