# KLD Load - depends on kernel - not avail. or version mismatch



## Mark Muscat (Sep 13, 2016)

I'm developing a device driver kld module to be hooked up to the FreeBSD system. Using a very simple default "hello" driver found below, I'm trying to `kld load` the module. However I'm getting the error:


```
KLD hello.ko: depends on kernel - not available or version mismatch
linker_load_file: Unsupported file type
```


```
#include <sys/paramh.>
#include <sys/module.h>
#include <sys/kernel.h>
#include <sys/systm.h>

static int hello_modevent(module_t mod __unused, int event, void *arg __unused)
{
          int error = 0;

          switch(event) {
          case MOD_LOAD:
                  uprintf("Hello,World!\n");
                  break;
          case MOD_UNLOAD:
                  uprintf("Good-bye, cruel World!\n");
                  break;
          default:
                  error = EOPNOTSUPP;
                  break;
          }
       
          return(error);
}

static moduledata_t hello_mod = {
          "hello",
          hello_modevent,
          NULL
};

DECLARE_MODULE(hello,hello_mod, SI_SUB_DRIVERS, SI_ORDER_MIDDLE);
```

Browsing online I have found hints that it might be related to the file header param.h not being the same version as the kern.osreldate, and sure enough the __FreeBSD_version in the param.h was 1100101 while the kern.osreldate was 1100500. I tried changing this value in param.h but to no avail. 

Further info:
`uname -a`:

```
11.0-PRERELEASE FreeBSD 11.0-PRERELEASE #14 R304256M root@FreeBSD_Test:/usr/obj/usr/home/driver1/source/11/sys/GENERIC amd64
```
(The directory /source/11 contains the source files from which I often compile and install a modified kernel).

As for `dmesg`, the error displayed is the exact same two lines specified above, with no further details.

What should I do at this point? Where to go from here?


----------



## SirDice (Sep 13, 2016)

Build the module against the exact same version of the source as your system.


----------



## Mark Muscat (Sep 13, 2016)

SirDice said:


> Build the module against the exact same version of the source as your system.


Thanks for your reply. 

Could you be more specific?


----------



## SirDice (Sep 13, 2016)

Apparently the source you have is not the same version as your system.


----------



## Mark Muscat (Sep 13, 2016)

SirDice said:


> Apparently the source you have is not the same version as your system.


I have completely built the kernel and installed it again to make sure everything is in it's latest version. However the problem still persists.

*Edit - Spelling*


----------



## SirDice (Sep 13, 2016)

Not just the kernel, make sure the rest of the world is updated too. That part will, for example, install the correct include files.


----------

