<div dir="ltr">Thank you</div><br><div class="gmail_quote"><div dir="ltr">On Thu, Aug 11, 2016 at 7:40 PM Greg KH <<a href="mailto:greg@kroah.com">greg@kroah.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">On Thu, Aug 11, 2016 at 07:25:45PM +0000, Matt M wrote:<br>
> I am just getting started with kernel module development, and I can't get<br>
> anything to compile.<br>
><br>
> I get the following errors:<br>
><br>
> In file included from main.c:1:0:<br>
> /usr/src/linux/include/linux/init.h:142:13: error: expected ‘=’, ‘,’, ‘;’,<br>
> ‘asm’ or ‘__attribute__’ before ‘load_default_modules’<br>
> void __init load_default_modules(void);<br>
> ^~~~~~~~~~~~~~~~~~~~<br>
> /usr/src/linux/include/linux/init.h:143:12: error: expected ‘=’, ‘,’, ‘;’,<br>
> ‘asm’ or ‘__attribute__’ before ‘init_rootfs’<br>
> int __init init_rootfs(void);<br>
> ^~~~~~~~~~~<br>
> /usr/src/linux/include/linux/init.h:285:13: error: expected ‘=’, ‘,’, ‘;’,<br>
> ‘asm’ or ‘__attribute__’ before ‘parse_early_param’<br>
> void __init parse_early_param(void);<br>
> ^~~~~~~~~~~~~~~~~<br>
> /usr/src/linux/include/linux/init.h:286:13: error: expected ‘=’, ‘,’, ‘;’,<br>
> ‘asm’ or ‘__attribute__’ before ‘parse_early_options’<br>
> void __init parse_early_options(char *cmdline);<br>
><br>
><br>
> The errors go on and on, but the majority look like that.<br>
><br>
> My code:<br>
><br>
> #include <linux/init.h><br>
> #include <linux/module.h><br>
><br>
> int main() {<br>
> return 0;<br>
> }<br>
><br>
><br>
> The compile command:<br>
> gcc -I /usr/src/linux/include/ main.c<br>
<br>
That's not how you compile a Linux kernel module, sorry.<br>
<br>
Please read the very good documentation for how to set up a Makefile for<br>
building a kernel module. It's in the kernel's Documentation/<br>
directory.<br>
<br>
best of luck,<br>
<br>
greg k-h<br>
</blockquote></div>