1, Fix it to use Extra_cflags. Stop
1). # Make kbuild_nopedantic=1
2). Relace all CFLAGS with Extra_cflags in the Makefile
==================================================
Replace the CFLAGS in the makefile with the extra_cflags.
The reason is that all Extra_ variables in the 2.6 kernel version only work in the defined Kbuild makefile.
The Extra_ variable can be used in all commands in Kbuild makefile.
$ (extra_cflags) is the option when compiling C source files with $ (CC).
Example:
# Drivers/sound/emu10kl/makefile
Extra_cflags + =-i$ (obj)
Ifdef DEBUG
Extra_cflags + =-demu10kl_debug
endif
This variable is required because the top-level makefile has the variable $ (CFLAGS) and is used as the compilation option for the entire source tree.
===================================================
For the "Linux device driver III", the example of "Chapter 4":
Delete the <linux/config.h>
Add the <linux/sched.h>
Ok, now the change to its derectory and complile it like this:
[[email protected] 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 is kind of method to solve this problem:
(1) Rplace all CFLAGS with Extra_cflags in the Makefile.
(2) Using the kbuild_nopedantic arg
[email protected] 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 on this blogHttp://www.phoronix.com/redblog/?p=blog&i=NTUwMA, would is to copy a config.h header file to Your/lib/modules/kernel-version/build/include/linux directory. If you had 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 to a self madeconfig.hFile
CODE#ifndef _linux_config_h
#define _linux_config_h
#include <linux/autoconf.h>
#endif3.dereferencing pointer to incomplete type error:
- /home/lingd/arm2410s/ldd3/chapter4/scumm/scumm.c:in function ' Scumm_open ':
- /home/lingd/arm2410s/ldd3/chapter4/scumm/scumm.c:54:error:dereferencing pointer to incomplete type
- /home/lingd/arm2410s/ldd3/chapter4/scumm/scumm.c:54:error:dereferencing pointer to incomplete type
- /home/lingd/arm2410s/ldd3/chapter4/scumm/scumm.c:in function ' scumm_release ':
- /home/lingd/arm2410s/ldd3/chapter4/scumm/scumm.c:96:error:dereferencing pointer to incomplete type
- /home/lingd/arm2410s/ldd3/chapter4/scumm/scumm.c:96:error:dereferencing pointer to incomplete type
- /home/lingd/arm2410s/ldd3/chapter4/scumm/scumm.c:in function ' Scumm_read ':
- /home/lingd/arm2410s/ldd3/chapter4/scumm/scumm.c:140:error:dereferencing pointer to incomplete type
- /home/lingd/arm2410s/ldd3/chapter4/scumm/scumm.c:140:error:dereferencing pointer to incomplete type
- /home/lingd/arm2410s/ldd3/chapter4/scumm/scumm.c:in function ' Scumm_write ':
- /home/lingd/arm2410s/ldd3/chapter4/scumm/scumm.c:210:error:dereferencing pointer to incomplete type
- /home/lingd/arm2410s/ldd3/chapter4/scumm/scumm.c:210:error:dereferencing pointer to incomplete type
Error statement:
- PRINTK (kern_debug "\"%s (PID%d) \ "Open Scumm device!\n", Current->comm, Current->pid);
The macro current is defined in the Arch/arm/include/asm/current.h,
- Static inline struct task_struct *get_current (void)
- {
- Return Current_thread_info ()->task;
- }
- #define CURRENT (Get_current ())
Cause of Error:
The compiler does not know the specific definition of the task_struct, so it cannot be referenced by current, unable to learn the type of its member Comm, PID, only reported "dereferencing pointer to incomplete type" task_ The struct is defined in <linux/sched.h>. In the source file header, plus # include <linux/sched.h>, you can solve the problem! "Dereferencing pointer to incomplete type" error, mostly due to the definition of struct/class/emun/union and so do not know the 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 ' cause: The new struct task_struct definition has changed, UID and euid in the cred structure. Workaround: Add header file Cred.h, change Current->uid to Current->cred->uid,current->euid to Current->cred->euid#include <linux/cred.h>108 if (scull_u_count &&109 &NB Sp (Scull_u_owner! = current->cred->uid) && /* allow user */110 (Scull_u_owner! = current->cred->euid) &&/* Allow whoever do su */... 117 Scull_u_owner = current->cred->uid; /* Grab It */
LDD problems with source code compilation