Ubuntu下的模块编程

编译打包和其他
回复
howema
帖子: 13
注册时间: 2007-07-10 10:27

Ubuntu下的模块编程

#1

帖子 howema » 2007-07-16 10:05

写了 个简单的模块程序,想在ubuntu6.10下看下运行结果,编译后总是提示没有头文件,不知道什么问题,在ubuntu下写模块程序还需要什么具体的操作呢?高手赐教。安装后的ubuntu的源代码在哪里可以找到阿?
howema
帖子: 13
注册时间: 2007-07-10 10:27

#2

帖子 howema » 2007-07-16 10:20

以下是错误提示:

dr.c:1:27: error: linux/module.h: No such file or directory
dr.c:3:27: error: linux/config.h: No such file or directory
dr.c:5:25: error: linux/init.h: No such file or directory
dr.c:7: error: expected declaration specifiers or ‘...’ before string constant
dr.c:7: warning: data definition has no type or storage class
dr.c: In function ‘hello_init’:
dr.c:13: error: ‘KERN_ALERT’ undeclared (first use in this function)
dr.c:13: error: (Each undeclared identifier is reported only once
dr.c:13: error: for each function it appears in.)
dr.c:13: error: expected ‘)’ before string constant
dr.c: In function ‘hello_exit’:
dr.c:23: error: ‘KERN_ALERT’ undeclared (first use in this function)
dr.c:23: error: expected ‘)’ before string constant
dr.c: At top level:
dr.c:27: warning: data definition has no type or storage class
dr.c:27: warning: parameter names (without types) in function declaration
dr.c:29: warning: data definition has no type or storage class
dr.c:29: warning: parameter names (without types) in function declaration
头像
stlxv
论坛版主
帖子: 8275
注册时间: 2006-05-03 0:39
来自: المريخ

#3

帖子 stlxv » 2007-07-22 17:24

内核头文件要装
PHP是最好的语言!不服来战!
howema
帖子: 13
注册时间: 2007-07-10 10:27

#4

帖子 howema » 2007-07-26 9:36

如何安装阿?
我的内核目录下找不到build那个文件。
smartyin
帖子: 99
注册时间: 2005-12-20 17:06

#5

帖子 smartyin » 2007-07-29 9:03

howema 写了:如何安装阿?
我的内核目录下找不到build那个文件。
linux-headers,其实module编程的依赖库是最少的,毕竟内核启动的时候可没什么给你依赖的,哈哈
sharpshootor
帖子: 34
注册时间: 2007-12-23 12:22

#6

帖子 sharpshootor » 2008-05-26 20:55

怎么没说如何装啊,晕
如何是我没看懂
apt-get install linux-source
:oops:
头像
BigSnake.NET
帖子: 12522
注册时间: 2006-07-02 11:16
来自: 廣州
联系:

#7

帖子 BigSnake.NET » 2008-05-26 21:03

aptitude install linux-headers-`uname -r`
^_^ ~~~
要理解递归,首先要理解递归。

地球人都知道,理论上,理论跟实际是没有差别的,但实际上,理论跟实际的差别是相当大滴。
回复