Guest dmiller.org Posted July 23, 2003 Report Share Posted July 23, 2003 I solved the error below when trying to compile a usb driver with Mandrake linux 9.1. The driver had 2 includes: linux/usb.h & linux/module.h which caused the following error: The Error Message =============================================== In file included from /usr/include/linux/prefetch.h:13, from /usr/include/linux/list.h:6, from /usr/include/linux/module.h:11, from activewire.c:28: /usr/include/asm/processor.h:55: `CONFIG_X86_L1_CACHE_SHIFT' undeclared here (not in a function) /usr/include/asm/processor.h:55: requested alignment is not a constant In file included from /usr/include/linux/module.h:297, from activewire.c:28: /usr/include/linux/version.h:2:2: #error "=======================================================" /usr/include/linux/version.h:3:2: #error "You should not include /usr/include/{linux,asm}/ header" /usr/include/linux/version.h:4:2: #error "files directly for the compilation of kernel modules." /usr/include/linux/version.h:5:2: #error "" /usr/include/linux/version.h:6:2: #error "glibc now uses kernel header files from a well-defined" /usr/include/linux/version.h:7:2: #error "working kernel version (as recommended by Linus Torvalds)" /usr/include/linux/version.h:8:2: #error "These files are glibc internal and may not match the" /usr/include/linux/version.h:9:2: #error "currently running kernel. They should only be" /usr/include/linux/version.h:10:2: #error "included via other system header files - user space" /usr/include/linux/version.h:11:2: #error "programs should not directly include <linux/*.h> or" /usr/include/linux/version.h:12:2: #error "<asm/*.h> as well." /usr/include/linux/version.h:13:2: #error "" /usr/include/linux/version.h:14:2: #error "To build kernel modules please do the following:" /usr/include/linux/version.h:15:2: #error "" /usr/include/linux/version.h:16:2: #error " o Have the kernel sources installed" /usr/include/linux/version.h:17:2: #error "" /usr/include/linux/version.h:18:2: #error " o Make sure that the symbolic link" /usr/include/linux/version.h:19:2: #error " /lib/modules/`uname -r`/build exists and points to" /usr/include/linux/version.h:20:2: #error " the matching kernel source directory" /usr/include/linux/version.h:21:2: #error "" /usr/include/linux/version.h:22:2: #error " o Now copy /boot/vmlinuz.version.h to" /usr/include/linux/version.h:23:2: #error " /lib/modules/`uname -r`/build/include/linux/version.h" /usr/include/linux/version.h:24:2: #error "" /usr/include/linux/version.h:25:2: #error " o When compiling, make sure to use the following" /usr/include/linux/version.h:26:2: #error " compiler option to use the correct include files:" /usr/include/linux/version.h:27:2: #error "" /usr/include/linux/version.h:28:2: #error " -I/lib/modules/`uname -r`/build/include" /usr/include/linux/version.h:29:2: #error "" /usr/include/linux/version.h:30:2: #error " instead of" /usr/include/linux/version.h:31:2: #error "" /usr/include/linux/version.h:32:2: #error " -I/usr/include/linux" /usr/include/linux/version.h:33:2: #error "" /usr/include/linux/version.h:34:2: #error " Please adjust the Makefile accordingly." /usr/include/linux/version.h:35:2: #error "=======================================================" In file included from activewire.c:28: /usr/include/linux/module.h:299: parse error before "UTS_RELEASE" =============================================== The Solution: 1) Go to Mandrake Control Centre 1.1) go to Software management 1.2) select option "all packages alphabetical" 1.3) select "kernel-source-2.4.21-0.13mdk" 1.4) install from installation CD3 - takes about 5-10 mins 2) Create a new directory "build" at /lib/modules/2.4.21-0.13mdk/ 3) create a new symbolic link: ln -s /usr/src/linux/include/ /lib/modules/2.4.21-0.13mdk/build/ This creates a symbolic link of a directory "include" within "build" pointing to /usr/src/linux/include/. Incidentally I found the "/" at the beginning of /usr/src/linux/include/ in the link statement important. 4) add to the compile command in the Makefile the option: -I /lib/modules/2.4.21-013mdk/build/include This makes sure that the "includes" come from /usr/src/linux/include/ via the symbolic link at /lib/modules/2.4.21-013mdk/build/include, and not from /usr/include/linux/ which causes all the errors above. From memory my compile command looks like: gcc -o activewire.o -I /lib/modules/2.4.21-013mdk/build/include activewire.c Hope all this helps. David Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.