亚洲av成人无遮挡网站在线观看,少妇性bbb搡bbb爽爽爽,亚洲av日韩精品久久久久久,兔费看少妇性l交大片免费,无码少妇一区二区三区

  免費(fèi)注冊(cè) 查看新帖 |

Chinaunix

  平臺(tái) 論壇 博客 文庫(kù)
最近訪問(wèn)板塊 發(fā)新帖
查看: 2180 | 回復(fù): 5
打印 上一主題 下一主題

請(qǐng)教一個(gè)很簡(jiǎn)單的模塊加載問(wèn)題 [復(fù)制鏈接]

論壇徽章:
0
跳轉(zhuǎn)到指定樓層
1 [收藏(0)] [報(bào)告]
發(fā)表于 2007-01-31 10:47 |只看該作者 |倒序?yàn)g覽
初學(xué)模塊化編程,試驗(yàn)一個(gè)最簡(jiǎn)單的hello.c模塊加載,程序如下:
#define MODULE
#include <linux/module.h>

int init_modele(void)
{ printk("<1>Hello,world\n");
   return 0; }

void cleanup_module(void)
{ printk("<1>Goodbye world\n"); }

使用命令#gcc -c hello.c編譯后生成hello.o
然后加載#insmod hello.o  
但是加載不上,說(shuō)版本不匹配,hello.o was complied for kernel version 2.4.20, while this kernel  is version 2.4.20-8.
這有什么區(qū)別嗎?怎么改就可以用了?

論壇徽章:
0
2 [報(bào)告]
發(fā)表于 2007-01-31 17:29 |只看該作者
gcc后面還該跟參數(shù),用于指定用那個(gè)include
試試下面的:
*  
*  hello-1.c - The simplest kernel module.
*/
#include <linux/module.h>        /* Needed by all modules */
#include <linux/kernel.h>        /* Needed for KERN_ALERT */

int init_module(void)
{
        printk("<1>Hello world 1.\n");

        /*
         * A non 0 return means init_module failed; module can't be loaded.
         */
        return 0;
}

void cleanup_module(void)
{
        printk(KERN_ALERT "Goodbye world 1.\n");
}

(2)Makefile
obj-m += hello-1.o
(3)make -C /usr/src/linux-`uname -r` SUBDIRS=$PWD modules
(4)insmod ./hello-1.ko
(5)dmesg|tail
(6)rmmod hello-1

論壇徽章:
0
3 [報(bào)告]
發(fā)表于 2007-01-31 22:12 |只看該作者
從第二步開(kāi)始都是在哪里做呢?我只會(huì)在終端里運(yùn)行shell命令


原帖由 mudga 于 2007-1-31 17:29 發(fā)表于 2樓  
gcc后面還該跟參數(shù),用于指定用那個(gè)include
試試下面的:
*  
*  hello-1.c - The simplest kernel module.
*/
#include <linux/module.h>        /* Needed by all modules */
#include <linux/ker ...

論壇徽章:
0
4 [報(bào)告]
發(fā)表于 2007-02-01 10:29 |只看該作者
原帖由 shanhuhai 于 2007-1-31 10:47 發(fā)表于 1樓  
初學(xué)模塊化編程,試驗(yàn)一個(gè)最簡(jiǎn)單的hello.c模塊加載,程序如下:
#define MODULE
#include <linux/module.h>

int init_modele(void)
{ printk("<1>Hello,world\n");
   return 0;  ...


這樣試試:

gcc -O2 -Wall -D__KERNEL__ -DMODULE -I/usr/src/linux-2.4/include/  -c hello.c

論壇徽章:
0
5 [報(bào)告]
發(fā)表于 2007-02-01 12:59 |只看該作者
謝謝你,可以加載了,
但是為什么不打印出hello world消息呢?


原帖由 ld_jia 于 2007-2-1 10:29 發(fā)表于 4樓  


這樣試試:

gcc -O2 -Wall -D__KERNEL__ -DMODULE -I/usr/src/linux-2.4/include/  -c hello.c

[ 本帖最后由 shanhuhai 于 2007-2-2 15:55 編輯 ]

論壇徽章:
0
6 [報(bào)告]
發(fā)表于 2007-02-03 16:26 |只看該作者
dmesg |tail
您需要登錄后才可以回帖 登錄 | 注冊(cè)

本版積分規(guī)則 發(fā)表回復(fù)

  

北京盛拓優(yōu)訊信息技術(shù)有限公司. 版權(quán)所有 京ICP備16024965號(hào)-6 北京市公安局海淀分局網(wǎng)監(jiān)中心備案編號(hào):11010802020122 niuxiaotong@pcpop.com 17352615567
未成年舉報(bào)專區(qū)
中國(guó)互聯(lián)網(wǎng)協(xié)會(huì)會(huì)員  聯(lián)系我們:huangweiwei@itpub.net
感謝所有關(guān)心和支持過(guò)ChinaUnix的朋友們 轉(zhuǎn)載本站內(nèi)容請(qǐng)注明原作者名及出處

清除 Cookies - ChinaUnix - Archiver - WAP - TOP