Find the answer to your Linux question:
Results 1 to 3 of 3
hi: I try to make the following codes. the makefile is as following PHP Code: INCLUDE        = / usr / src / kernels / 2.6.35.6 - 45.fc14 . i686 /include CC          =  ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Jun 2011
    Posts
    1

    about compile error


    hi:

    I try to make the following codes.
    the makefile is as following

    PHP Code:

    INCLUDE        = /usr/src/kernels/2.6.35.6-45.fc14.i686/include
    CC         gcc
    CFLAGS         
    = -D__KERNEL__ -I$(INCLUDE) -DMODULE -Wall -O2

    TARGET    
    test
    SRC    
    test.c

    all
    : $(TARGET).o

    clean
    :
        
    rm -*.*~ core 

    and the source code is followings:

    PHP Code:

    #include <linux/init.h>
    #include <linux/module.h>
    MODULE_LICENSE("GPL");
    static 
    int hello_init(void)
    {
    printk(KERN_ALERT "Testing\n");
    return 
    0;
    }
    static 
    void hello_exit(void)
    {
    printk(KERN_ALERT "OK\n");
    }
    module_init(hello_init);
    module_exit(hello_exit); 
    after execute ./make, the compiler show error and say can not find the file asm/processor.h. my system is fedora14, how to solve the problem,
    ,any suggestions is highly appreciated.Thanks

  2. #2
    Just Joined!
    Join Date
    May 2011
    Posts
    5
    processor.h should be located in $(INCLUDE)/asm.

  3. #3
    Just Joined!
    Join Date
    Jul 2011
    Posts
    16
    You have written a module, you need to use the following Makefile to compile it.

    vim Makefile

    obj-m :=test.o

    all:
    make -C /lib/modules/$(shell uname -r)/build M=$(PWD) modules

    Now run make tool, then a file test.ko is generated.
    Last edited by MikeTbob; 07-30-2011 at 08:48 PM. Reason: Deleted advertising

  4. $spacer_open
    $spacer_close

Posting Permissions

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