Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1071092
  • 博文数量: 242
  • 博客积分: 10209
  • 博客等级: 上将
  • 技术积分: 3028
  • 用 户 组: 普通用户
  • 注册时间: 2008-03-12 09:27
文章分类

全部博文(242)

文章存档

2014年(1)

2013年(1)

2010年(51)

2009年(65)

2008年(124)

我的朋友

分类: LINUX

2009-06-10 23:30:52

1./usr/src/linux/include/linux是给编译内核用的
  /usr/include/linux是给编译应用程序用的

  /usr/include/linux应该是到/usr/src/linux/include/linux的连接
  /usr/include/asm应该是到/usr/src/linux/include/asm的连接

  /usr/src/linux/include/asm连接到当前目录的asm-i386

  以前一直是这样的。在早期讲Kernel编译的文章中经常提醒用户自己做好以下工作:
   ln -s /usr/src/linux/include/linux /usr/include/linux
   ln -s /usr/src/linux/include/asm /usr/include/asm 

  后来的发布一般都已经做好了。
 
2.但是在RH 7.1中改了。
  /usr/src/include/linux和/usr/src/include/asm都是真实目录了。

 
在最新的发布中,似乎更推荐两者分开。
  绝大多数“普通”程序不需要内核头文件,事实上如果直接引用它们会出错。这些程序应该引用那些编译glibc所用的头文件,它们位于系统的/usr/include/linux和/usr/include/asm目录下。
redhat的/usr/include属于glibc,不是给内核用的,虽然也包含asm和linux目录,但是简化过的,编译内核模块偶尔能成功,幸运而已,建议编译内核时加-nostdinc参数,以防止使用了错误的目录。

3.实例

在redhat9.0(linux-2.4.20-8)环境下编译了一个和netfilter相关的内 核程序程序,当我用gcc -O -c -I/usr/src/linux/include examplemod.c编译时,就没有问题,但我用gcc -O -c -I/usr/include examplemod.c编译时就不能通过,出现如下的错物欲告警:

/usr/include/linux/netfilter_ipv4.h:53: `INT_MIN' undeclared here (not in a function)
/usr/include/linux/netfilter_ipv4.h:53: enumerator value for `NF_IP_PRI_FIRST' not integer constant
/usr/include/linux/netfilter_ipv4.h:59: `INT_MAX' undeclared here (not in a function)
/usr/include/linux/netfilter_ipv4.h:59: enumerator value for `NF_IP_PRI_LAST' not integer constant
test1.c:21: warning: `struct net_device' declared inside parameter list
test1.c:21: warning: its scope is only this definition or declaration, which is probably not what you want
test1.c:21: warning: `struct sk_buff' declared inside parameter list
test1.c: In function `init_module':
test1.c:37: invalid use of undefined type `struct nf_hook_ops'
test1.c:38: invalid use of undefined type `struct nf_hook_ops'
test1.c:39: invalid use of undefined type `struct nf_hook_ops'
test1.c:40: invalid use of undefined type `struct nf_hook_ops'
/usr/include/linux/byteorder/swab.h: At top level:
test1.c:14: storage size of `nfho' isn't known

阅读(2676) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~