1、Fix it to use EXTRA_CFLAGS.  Stop

1). # make KBUILD_NOPEDANTIC=1
2). Relace all CFLAGS with EXTRA_CFLAGS in the Makefile

==================================================

将makefile中的 CFLAGS 替换成 EXTRA_CFLAGS就可以了。

原因是在2.6的内核的版本中所有的 EXTRA_ 变量只在所定义的Kbuild Makefile中起作用。

EXTRA_ 变量可以在Kbuild Makefile中所有命令中使用。

$(EXTRA_CFLAGS) 是用 $(CC) 编译C源文件时的选项。

例子:

# drivers/sound/emu10kl/Makefile

EXTRA_CFLAGS += -I$(obj)

ifdef DEBUG

EXTRA_CFLAGS += -DEMU10KL_DEBUG

endif

该变量是必须的,因为顶层Makefile拥有变量 $(CFLAGS) 并用来作为整个源代码树的编译选项。

===================================================

For the "Linux device driver III", the example of "chapter 4":
Delete the <linux/config.h>
Add the <linux/sched.h>

Ok, now change into its derectory and complile it like this:

[root@localhost scull]# make
make -C /lib/modules/2.6.24.2-2lp/build M=/root/Desktop/examples/scull LDDINC=/root/Desktop/examples/scull/../include modules
make[1]: Entering directory `/usr/src/kernels/2.6.24.2-2lp-i686'
scripts/Makefile.build:46: *** CFLAGS was changed in "/root/Desktop/examples/scull/Makefile". Fix it to use EXTRA_CFLAGS. Stop.
make[1]: *** [_module_/root/Desktop/examples/scull] Error 2
make[1]: Leaving directory `/usr/src/kernels/2.6.24.2-2lp-i686'
make: *** [modules] Error 2

There are two kind of method to solve this problem:

(1)Rplace all CFLAGS with EXTRA_CFLAGS in the Makefile.

(2)Using the KBUILD_NOPEDANTIC arg
[root@localhost scull]# make KBUILD_NOPEDANTIC=1
make -C /lib/modules/2.6.24.2-2lp/build M=/root/Desktop/examples/scull LDDINC=/root/Desktop/examples/scull/../include modules
make[1]: Entering directory `/usr/src/kernels/2.6.24.2-2lp-i686'
CC [M] /root/Desktop/examples/scull/main.o
CC [M] /root/Desktop/examples/scull/pipe.o
CC [M] /root/Desktop/examples/scull/access.o
LD [M] /root/Desktop/examples/scull/scull.o
Building modules, stage 2.
MODPOST 1 modules
CC      /root/Desktop/examples/scull/scull.mod.o
LD [M] /root/Desktop/examples/scull/scull.ko
make[1]: Leaving directory `/usr/src/kernels/2.6.24.2-2lp-i686'

2、linux/config.h: No such file or directory

$ make
make -C /lib/modules/2.6.18-1.2798a_FC6/build SUBDIRS=/home/njc/stuff/linux-labjack/driver/linux-2.6 modules
make[1]: Entering directory `/usr/src/redhat/BUILD/kernel-2.6.181.2798a_FC6'
CC [M] /home/njc/stuff/linux-labjack/driver/linux-2.6/labjack.o
/home/njc/stuff/linux-labjack/driver/linux-2.6/labjack.c:43:26: error: linux/config.h: No such file or directory
make[2]: *** [/home/njc/stuff/linux-labjack/driver/linux-2.6/labjack.o] Error 1
make[1]: *** [_module_/home/njc/stuff/linux-labjack/driver/linux-2.6] Error 2
make[1]: Leaving directory `/usr/src/redhat/BUILD/kernel-2.6.181.2798a_FC6'
make: *** [default] Error 2
 
A solution, which I based from a discussion in this bloghttp://www.phoronix.com/redblog/?p=blog&i=NTUwMA, would be to copy a config.h header file to your /lib/modules/KERNEL-VERSION/build/include/linux directory. If you have a previous kernel build on your computer you can copy the file from your /lib/modules/OLD-KERNEL-VERSION/build/include/linux directory. Alternatively you can just copy the code below into a self made config.h file

CODE
#ifndef _LINUX_CONFIG_H
#define _LINUX_CONFIG_H

#include <linux/autoconf.h>

#endif

3.dereferencing pointer to incomplete type

错误:

  1. /home/lingd/arm2410s/ldd3/chapter4/scumm/scumm.c: In function 'scumm_open':
  2. /home/lingd/arm2410s/ldd3/chapter4/scumm/scumm.c:54: error: dereferencing pointer to incomplete type
  3. /home/lingd/arm2410s/ldd3/chapter4/scumm/scumm.c:54: error: dereferencing pointer to incomplete type
  4. /home/lingd/arm2410s/ldd3/chapter4/scumm/scumm.c: In function 'scumm_release':
  5. /home/lingd/arm2410s/ldd3/chapter4/scumm/scumm.c:96: error: dereferencing pointer to incomplete type
  6. /home/lingd/arm2410s/ldd3/chapter4/scumm/scumm.c:96: error: dereferencing pointer to incomplete type
  7. /home/lingd/arm2410s/ldd3/chapter4/scumm/scumm.c: In function 'scumm_read':
  8. /home/lingd/arm2410s/ldd3/chapter4/scumm/scumm.c:140: error: dereferencing pointer to incomplete type
  9. /home/lingd/arm2410s/ldd3/chapter4/scumm/scumm.c:140: error: dereferencing pointer to incomplete type
  10. /home/lingd/arm2410s/ldd3/chapter4/scumm/scumm.c: In function 'scumm_write':
  11. /home/lingd/arm2410s/ldd3/chapter4/scumm/scumm.c:210: error: dereferencing pointer to incomplete type
  12. /home/lingd/arm2410s/ldd3/chapter4/scumm/scumm.c:210: error: dereferencing pointer to incomplete type
 
出错语句:
  1. printk(KERN_DEBUG "\"%s(pid %d)\" open scumm device!\n", current->comm, current->pid);
宏current定义在arch/arm/include/asm/current.h中,
  1. static inline struct task_struct *get_current(void)
  2. {
  3. return current_thread_info()->task;
  4. }
  5. #define current (get_current())
出错原因:
编译器不知道task_struct的具体定义,因此,无法解引用current,无法获知其成员comm、pid的类型,才报“dereferencing pointer to incomplete type”
task_struct定义在<linux/sched.h>中。在源文件头,加上#include <linux/sched.h>,即可解决问题!
“dereferencing pointer to incomplete type”错误,大多也是因为不知道struct/class/emun/union等的定义而引起的
 

4、'struct task_struct' has no member named 'uid'

/home/jqzeng/workSpace/ldd3/ldd3-samples-1.0.0/scull/access.c:107:29: error: 'struct task_struct' has no member named 'uid'
/home/jqzeng/workSpace/ldd3/ldd3-samples-1.0.0/scull/access.c:108:29: error: 'struct task_struct' has no member named 'euid'
原因:新的struct task_struct 定义有变化,uid和euid在cred结构体中。
解决办法:加头文件cred.h,将 current->uid改为current->cred->uid,current->euid改为current->cred->euid
#include <linux/cred.h>
108         if (scull_u_count &&
109                         (scull_u_owner != current->cred->uid) &&  /* allow user */
110                         (scull_u_owner != current->cred->euid) && /* allow whoever did su */
...
117                 scull_u_owner = current->cred->uid; /* grab it */

ldd源码编译出现的问题的更多相关文章

  1. ffplay源码编译

    ffplay是ffmpeg源码中一个自带的开源播放器组件,支持本地视频文件的播放以及在线流媒体播放,很多商业播放器都是基于ffplay定制而来的.ffplay中的代码充分利用了ffmpeg中的函数库, ...

  2. ffmpeg源码编译环境搭建

    ffmpeg是视频开发最常用到的开源软件,FFmpeg功能强大,用途广泛,提供几乎所有你能够想到的与视频开发相关的操作,许多商业软件都以ffmpeg为基础进行开发定制. FFmpeg: FFmpeg ...

  3. Android 5.0源码编译问题

    如果是自己通过repo和git直接从google官网上download的源码,请忽略这个问题,但是由于google在国内被限制登录,通过这一种方法不是每个人都能download下来源码,通常的做法就是 ...

  4. Android stdio Apktool源码编译

    Android Apktool源码编译 标签(空格分隔): Android Apktool 源码编译 需求 习惯NetBeans调试smali需要用Apktool反编译apk,需要用-d的参数才能生成 ...

  5. SSH/SSL 源码编译安装简易操作说明

    环境:CentOS 6.7 安全加固需求,由于某盟扫描系统主机有SSL系列漏洞,客户要求必须修复: 解决方案:将SSH/SSL升级到最新版本,删除SSL旧版本(实测不删除旧版本某盟扫描无法通过). 当 ...

  6. Hadoop源码编译过程

    一.           为什么要编译Hadoop源码 Hadoop是使用Java语言开发的,但是有一些需求和操作并不适合使用java,所以就引入了本地库(Native Libraries)的概念,通 ...

  7. World Wind .NET源码编译问题处理

    World  Wind  .NET源码编译问题处理 下载了World_Wind_1.4.0_Source源码(http://worldwindcentral.com/wiki/NASA_World_W ...

  8. 源码编译安装 MySQL 5.5.x 实践

    1.安装cmakeMySQL从5.5版本开始,通过./configure进行编译配置方式已经被取消,取而代之的是cmake工具.因此,我们首先要在系统中源码编译安装cmake工具. # wget ht ...

  9. Linux 安装node.js ---- 源码编译的方式

    一 : 普通用户: 安装前准备环境: 1.检查Linux 版本 命令: cat /etc/redhat-release 2.检查 gcc.gcc-c++ 是否安装过 命令: rpm -q gcc rp ...

随机推荐

  1. c++数据类型漫谈

    在计算机眼里所有数据都是0101,二进制才是物理世界的主宰,c++的数据类型相对其他高级语言是相对较细的,因为是继承C而来,但是c++为什么要设计这么多数据类型呢?因为人类难以理解二进制,这就是数据类 ...

  2. Eclipse导入文件识别不了jsp怎么办

    1.在出现错误代码页开始处加上<%@ page import="java.util.*"%>,把包引进来2.然后右击项目,依次选择Properties->Java ...

  3. centos nginx配置https

    1.获取https证书: 用的阿里的免费证书: 参考:https://blog.csdn.net/chandoudeyuyi/article/details/71246255 2.修改nginx配置文 ...

  4. H5使用codovar插件实现支付宝支付(支付宝APP支付模式,前端)

    H5打包的app实现支付及支付宝支付,本章主要详解支付宝支付,微信支付请查看另一篇“H5使用codovar插件实现微信支付(微信APP支付模式,前端)” ps:本文只试用H5开发的,支付宝 APP支付 ...

  5. vue cli 3

    介绍 Vue CLI 是一个基于 Vue.js 进行快速开发的完整系统 通过 @vue/cli 搭建交互式的项目脚手架. 通过 @vue/cli + @vue/cli-service-global 快 ...

  6. MM-科目自动分配

    SAP系统篇 MM自动记账解析之基本概念(01) https://blog.csdn.net/qq_33641781/article/details/78027802 MM自动记账解析之功能实现(02 ...

  7. 基于C/S 结构的IM即时通讯软件--上篇

    目的:实现类似QQ群聊的聊天室,可以看到好友列表及互相传送信息. 分析:可基于C/S结构实现即时通讯 1.创建基于对话框的MFC程序(支持windows套接字),并增加相应的类与结构体,完善对话框界面 ...

  8. 使用Idea从github上获取项目

    转载自:https://www.cnblogs.com/30go/p/7909246.html 整体分三步: 下载和安装git 配置idea 从git获取项目 详细步骤: 1. 下载和安装git 下载 ...

  9. centos7.4下的KVM虚拟机安装使用

    本来是用的vmware,不过后来想试下KVM,想着装个ZSTACK也行,结果zstack使用网络安装没搞明白,把物理机系统毁了,这下彻底完蛋了,只好还装个centos了,但是又不想用VMWARE就想起 ...

  10. Linux gzip命令

    语法: gzip [-acdfhlLnNqrtvV][-S <压缩字尾字符串>][-<压缩效率>][--best/fast][文件...] 或 gzip [-acdfhlLnN ...