天天看點

記憶體配置設定子產品編譯出錯

編譯子產品時,出現以下問題

/home/alloc_mem.c:13: warning: function declaration isn't a prototype

/home/alloc_mem.c: In function 'alloc_init':

/home/alloc_mem.c:14: error: implicit declaration of function'kmalloc'

/home/alloc_mem.c:14: warning: assignment makes pointer from integer without a cast

/home/alloc_mem.c:19: warning: assignment makes pointer from integer without a cast

/home/alloc_mem.c: At top level:

/home/alloc_mem.c:25: warning: function declaration isn't a prototype

/home/alloc_mem.c: In function 'alloc_exit':

/home/alloc_mem.c:26: error: implicit declaration of function 'kfree'

/home/alloc_mem.c:27: warning: passing argument 1 of 'free_pages' makes integer from pointer without a cast

make[2]: *** [/home/shiyan/4-4-1/neicun/alloc_mem.o] Error 1

make[1]: *** [_module_/home/shiyan/4-4-1/neicun] Error 2

make[1]: Leaving directory `/home/shiyan/neihe/linux-2.6.36.2-v1.05'

make: *** [all] Error 2

在網上找了一下,是缺少了一個頭檔案#include <linux/slab.h>加上之後就沒問題了,另外還有驅動的加載函數還有解除安裝函數也要在括号中注意加上void,避免一些不必要的錯誤

1.在編譯核心時 出現drivers/char/memdev.c:174: error: implicit declaration of function 'kmalloc' 在網上找了下原來是少了頭檔案#include<linux/slab.h>。

2.app-mem.c:9: warning: incompatible implicit declaration of built-in function 'strcpy' 原因是缺少頭檔案#include<string.h>。    /home/shiyan/5-1-1CQD/ioctlqudong/memdev.c:84: error: unknown field 'ioctl'specified in initializer

在linux-2.6.36核心上加載編譯驅動時,出現

 error:unknown field 'ioctl' specified in initializer

原因是:在2.6.36核心上file_operations發生了重大的改變:

原先的

  int (*ioctl)(struct inode*, struct file*, unsigned int, unsigned long);

被改為了       

   long (*unlocked_ioctl) (struct file *, unsigned int, unsigned long);

        long (*compat_ioctl) (struct file *, unsigned int, unsigned long);

因而在實際驅動中,我們需要将原先的寫的ioctl函數頭給改成下面的unlocked_ioctl,在file_operations結構體的填充中也是一樣。

繼續閱讀