Find the answer to your Linux question:
Results 1 to 2 of 2
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined! probe's Avatar
    Join Date
    Oct 2009
    Belgrade, Serbia

    gcc compile kernel 2.6 module

    Hi all,

    Does anybody know how should look gcc compilation line or Makefile
    to compile kernel module for kernel 2.6

    In 2.4 it looks like this:
    TARGET := hello-1
    WARN := -W -Wall -Wstrict-prototypes -Wmissing-prototypes
    INCLUDE := -isystem /lib/modules/`uname -r`/build/include
    CC := gcc-3.0

    ${TARGET}.o: ${TARGET}.c

    .PHONY: clean

    rm -rf ${TARGET}.o

    and for multiple source files, like this:

    hello.o: hello2_start.o hello2_stop.o
    ld -m elf_i386 -r -o hello2.o hello2_start.o hello2_stop.o

    start.o: hello2_start.c
    ${CC} ${MODCFLAGS} -c hello2_start.c

    stop.o: hello2_stop.c
    ${CC} ${MODCFLAGS} -c hello2_stop.c

    Kind regards,

    Dragoslav Zaric
    MSc Astrophysics
    Professional programmer

  2. #2
    Linux Guru Rubberman's Avatar
    Join Date
    Apr 2009
    I can be found either 40 miles west of Chicago, in Chicago, or in a galaxy far, far away.
    Why are you trying to do this manually? The kernel sources come with a Makefile, but before you build the kernel you need to run (as regular user) one of the configuration tools (make menuconfig, make xconfig, etc), then run make and make install (as root). Kernel make files are very complex and should not be edited manually, or things are likely to not work as expected.

    If you need to create a make file for a kernel module and/or driver that you are adding to the kernel, then look at existing ones in your kernel build tree for a template.
    Sometimes, real fast is almost as good as real time.
    Just remember, Semper Gumbi - always be flexible!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts