Announcement

Collapse
No announcement yet.

Compiling a Kernel Module - Error

Collapse
This topic is closed.
X
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Compiling a Kernel Module - Error

    Trying to compile lirc_imontouch module so I can get my touchscreen working, but it gives an error that doesn't make sense:

    Code:
    /home/bill/dl/lirc_imontouch-0.1b/lirc_imontouch.c:46:29: error: drivers/kcompat.h: No such file or directory                          
    /home/bill/dl/lirc_imontouch-0.1b/lirc_imontouch.c:47:26: error: drivers/lirc.h: No such file or directory
    Well the module source is in my user directory, but {source}/drivers/kcompat.h and lirc.h certainly are there. They are symlinks that link to the actual files in the next directory up, and those files are there.

    I've tried echoing what it thinks SUBDIRS is, but bash commands do not seem to work in a makefile.

    Here's what the Makefile has:
    Code:
    MDIR = drivers/misc
    
    EXTRA_CFLAGS = -DEXPORT_SYMTAB
    KBUILD_CFLAGS += -DIRCTL_DEV_MAJOR=61
    CURRENT = $(shell uname -r)
    KDIR = /lib/modules/$(CURRENT)/build
    PWD = $(shell pwd)
    DEST = /lib/modules/$(CURRENT)/kernel/$(MDIR)
    
    obj-m   := lirc_dev.o lirc_imontouch.o
    
    default:
    	make -C $(KDIR) SUBDIRS=$(PWD) modules
    
    install:
    	su -c "cp -v lirc_imontouch.ko lirc_dev.ko $(DEST) && /sbin/depmod -a"
    
    clean:
    	-rm -f *.o *.ko .*.cmd .*.flags *.mod.c
    
    -include $(KDIR)/Rules.make
    BTW, there is no drivers/misc directory in the source, if that matters.


    #2
    Re: Compiling a Kernel Module - Error

    nobody's picked this one up, so...
    don't really know what the problem is and can't test.
    but commands can certainly be executed within a makefile.
    you can see this yourself, as your makefile is full of commands (i.e. pwd, make, su, cp, rm).
    what SUBDIRS is you can see already in the output.
    the notation in
    Code:
    ...
    <tab>	make -C $(KDIR) SUBDIRS=$(PWD) modules
    ...
    is such that the value of both KDIR and PWD is output.
    otherwise you can do something like:
    Code:
    default:
    <tab>	@echo "KDIR is..." ${KDIR}
    <tab>	@echo "PWD is..." ${PWD}
    <tab>	make -C $(KDIR) SUBDIRS=$(PWD) modules
    hth
    gnu/linux is not windoze

    Comment


      #3
      Re: Compiling a Kernel Module - Error

      Hm, I tried
      echo "KDIR=$(KDIR)"
      ... but it didn't work. I see you have subtle differences in your command.

      But I've also gotten guidance over on the Debian forum, and it works, although I know not why.

      Open lirc_imontouch.c in your favorite editor o change lines 46-48

      Code:

      #include <drivers/kcompat.h>
      #include <drivers/lirc.h>
      #include <drivers/lirc_dev/lirc_dev.h>


      to

      Code:

      #include "drivers/kcompat.h"
      #include "drivers/lirc.h"
      #include "drivers/lirc_dev/lirc_dev.h"

      Comment


        #4
        Re: Compiling a Kernel Module - Error

        Originally posted by Quantumstate
        Hm, I tried
        echo "KDIR=$(KDIR)"
        ... but it didn't work. I see you have subtle differences in your command.
        ...
        yeah.
        that subtle difference is what makes the difference between working (output) and not working (no output).
        another thing is that each command line (those under the target/dependencies line) must start with a <tab>.

        the difference between
        #include <drivers/kcompat.h>
        #include <drivers/lirc.h>
        #include <drivers/lirc_dev/lirc_dev.h>
        and
        #include "drivers/kcompat.h"
        #include "drivers/lirc.h"
        #include "drivers/lirc_dev/lirc_dev.h"
        is that the former, with <...>, has the compiler base its headers lookup in the system's dir (i.e. /usr/include, or whatever).
        the latter with, "...", has the compiler base the lookup in your current working dir.

        good then.
        all sorted.
        take care.
        cheers
        gnu/linux is not windoze

        Comment


          #5
          Re: Compiling a Kernel Module - Error

          Interesting, thanks jankushka.

          Comment

          Working...
          X