0

I am trying to build an out-of-tree linux kernel that should take into account external headers files comming from pre- compiled and installed custom libraries. My linux module will use functions from a shared library via a C-interface. How is it possible to prevent kernel Makefile of the existence of such files?

    obj-m+= hello_module.o
    $(MAKE) -C $(KDIR) M=$(OUTDIR) modules
    #additional include path
    INCLUDES :=\ 
             -I $(PROJECT_ROOT)/deps1
             -I $(PROJECT_ROOT)/deps2
             -I $(PROJECT_ROOT)/deps3

So how can I include this in $(MAKE) line above? Thanks in advance, Rgds sahbi

sahbi.m
  • 39
  • 1
  • 9
  • 3
    `... headers files comming from already compiled and installed custom libraries.` - Linux *kernel* module **cannot be linked** with *user space* libraries. That is, you may include given header files for compilation process, but resulted module will contain *unresolved* symbols, so it couldn't be loaded into the kernel. – Tsyvarev Jun 07 '17 at 10:32
  • So what should I do instead? Actually external libraries are dynamic that's why I couldn't include once the headers in OUTDIR. I have noticed that was possible with _VxWorks_, So my question, – sahbi.m Jun 07 '17 at 11:24
  • How do you plan to link dynamic libraries to the kernel? – stark Jun 07 '17 at 11:38
  • 1
    Possible duplicate of [Linking shared library in linux kernel](https://stackoverflow.com/questions/31928255/linking-shared-library-in-linux-kernel) – Tsyvarev Jun 07 '17 at 11:42
  • example deps1 = boost, deps2 = header files template, deps3= a C-iterface using the librairy in deps2 – sahbi.m Jun 07 '17 at 12:51

1 Answers1

0

You cannot link user space libraries into modules. But you can link multiple files with the following Makefile:

obj-m := combinedmodule.o
combinedmodule-objs := part1.o part2.o


all:
        make -C $(KERNEL_SRC) M=$(PWD) modules
Appyx
  • 1,145
  • 1
  • 12
  • 21