Search code examples
ceclipselinux-kernelkerneleclipse-cdt

How to add linux headers to Eclipse CDT in Windows


I was trying to code kernel modules (using pure C) in Eclipse via CDT on Linux Mint, but it seems the CDT doesn't detect the libraries. The libraries which are unresolved are :

#include <linux/module.h>
#include <linux/slab.h>  
#include <linux/cdev.h>
#include <asm/atomic.h>
#include <linux/list.h>
....

How do I get these libraries into Eclipse and make it detect it so that I can use them for development? I generally use Eclipse for Java on Windows and it allows easy library importing, but I do not understand the CDT on Linux.


Solution

  • The question is flawed. The question code lists several '#include' files, and call them 'libraries'; when in fact, they are 'header files' (not libraries).

    The 'header files' all define symbols to the compiler which are resolved by the kernel when the kernel module is loaded (insmod, etc.).

    The specific symbols, defined by the 'header files' are not part of a library that must be linked with the code (at link-time). Rather these symbols are embodied by the kernel itself. "The kernel -is- the library" (to be blunt). You will not find libraries to link the symbols in those header files.

    I don't believe that you will find it practical (if even possible) to use Eclipse to build a kernel module.

    Rather, use the kbuild environment supplied by Linux. On your Linux system, read the file:

    /usr/src/linux/Documentation/kbuild/modules.txt
    

    That will start you on the right path to building Linux kernel modules.