kernelnewbies.kernelnewbies.org archive mirror
 help / color / mirror / Atom feed
From: greg@kroah.com (Greg KH)
To: kernelnewbies@lists.kernelnewbies.org
Subject: Kernel module compilation errors
Date: Thu, 11 Aug 2016 21:40:46 +0200	[thread overview]
Message-ID: <20160811194046.GA1283@kroah.com> (raw)
In-Reply-To: <CA+tMuX0Fc+amQ52jtZ+Hmn_dzC-wXak5NaRRu0-L2QJTwToc3w@mail.gmail.com>

On Thu, Aug 11, 2016 at 07:25:45PM +0000, Matt M wrote:
> I am just getting started with kernel module development, and I can't get
> anything to compile.
> 
> I get the following errors:
> 
> In file included from main.c:1:0:
> /usr/src/linux/include/linux/init.h:142:13: error: expected ?=?, ?,?, ?;?,
> ?asm? or ?__attribute__? before ?load_default_modules?
> ?void __init load_default_modules(void);
> ? ? ? ? ? ? ?^~~~~~~~~~~~~~~~~~~~
> /usr/src/linux/include/linux/init.h:143:12: error: expected ?=?, ?,?, ?;?,
> ?asm? or ?__attribute__? before ?init_rootfs?
> ?int __init init_rootfs(void);
> ? ? ? ? ? ? ^~~~~~~~~~~
> /usr/src/linux/include/linux/init.h:285:13: error: expected ?=?, ?,?, ?;?,
> ?asm? or ?__attribute__? before ?parse_early_param?
> ?void __init parse_early_param(void);
> ? ? ? ? ? ? ?^~~~~~~~~~~~~~~~~
> /usr/src/linux/include/linux/init.h:286:13: error: expected ?=?, ?,?, ?;?,
> ?asm? or ?__attribute__? before ?parse_early_options?
> ?void __init parse_early_options(char *cmdline);
> 
> 
> The errors go on and on, but the majority look like that.
> 
> My code:
> 
> #include <linux/init.h>
> #include <linux/module.h>
> 
> int main() {
> return 0;
> }
> 
> 
> The compile command:
> gcc -I /usr/src/linux/include/ main.c

That's not how you compile a Linux kernel module, sorry.

Please read the very good documentation for how to set up a Makefile for
building a kernel module.  It's in the kernel's Documentation/
directory.

best of luck,

greg k-h

  reply	other threads:[~2016-08-11 19:40 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-08-11 19:25 Kernel module compilation errors Matt M
2016-08-11 19:40 ` Greg KH [this message]
2016-08-11 21:50   ` Matt M
2016-08-12 17:44     ` Matt M
2016-08-12 17:46       ` Matt M

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20160811194046.GA1283@kroah.com \
    --to=greg@kroah.com \
    --cc=kernelnewbies@lists.kernelnewbies.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).