# Compile dynamic kernel module into kernel



## sandm44n (Dec 5, 2018)

Sorry in advance if this question has been answered before - I'm quite new to FreeBSD and don't know the exact terminology I should be using.

I have a 3rd party dynamic kernel module that I can load via kldload. I know that FreeBSD supports compiling in certain modules directly into the kernel. For example, the manpage for aac says that if I add


```
device aac
device aacp
```

to my kernel config file, when I build the kernel, it will link it against this library. That same module can also by dynamically loaded, since it's in 
	
	



```
/boot/kernel
```
.

Is there a simple way to link the kernel against a 3rd party module that's otherwise loaded dynamically? I have been able to build the kernel and world from scratch, but what I need more knowledge on is the necessary relevant configuration options to do something like this


----------



## ShelLuser (Dec 6, 2018)

Don't bother. Because in the end there is no significant difference between the two options and you're only overcomplicating things.


----------



## sandm44n (Dec 6, 2018)

ShelLuser said:


> Don't bother. Because in the end there is no significant difference between the two options and you're only overcomplicating things.


Thank you for your reply. I would still prefer to know how to do it, even if it's not useful, because I want to learn more about the kernel in a way that interests me. And this is something that interests me


----------



## SirDice (Dec 6, 2018)

Is the module pre-compiled/binary? Or do you have the source code? Source code is probably easier to work with as you can just treat is as a "new" module and integrate it into the existing kernel source tree. I'm not sure how you would link a binary module into a compiled kernel. I'm sure it's possible but would probably require a lot of fiddling to get it to link at the right time in the right place.


----------



## sandm44n (Dec 6, 2018)

SirDice said:


> Is the module pre-compiled/binary? Or do you have the source code? Source code is probably easier to work with as you can just treat is as a "new" module and integrate it into the existing kernel source tree. I'm not sure how you would link a binary module into a compiled kernel. I'm sure it's possible but would probably require a lot of fiddling to get it to link at the right time in the right place.


I have the source code! It's part of a larger project though, so building it individually may be a bit of a pain


----------

