我一直在尝试编译一个非常古老的程序,实际上是用于内核的
我之前遇到过一个问题缺少 Modversions.h现在已经解决了,但还有另一个问题。
In file included from /lib/modules/3.8.0-29-generic/build/include/linux/types.h:5:0,
from /lib/modules/3.8.0-29-generic/build/include/linux/list.h:4,
from /lib/modules/3.8.0-29-generic/build/include/linux/module.h:9,
from kaodv-mod.c:30:
/lib/modules/3.8.0-29-generic/build/include/uapi/linux/types.h:4:23: fatal error: asm/types.h: No such file or directory
compilation terminated.
make[1]: *** [kaodv-mod.o] Error 1
make[1]: Leaving directory `/home/vm1/aodv-12-12-13/lnx'
make: *** [kaodv] Error 2
文件 /lib/modules/3.8.0-29-generic/build/include/uapi/linux/types.h 是一个 linux 头文件,我不明白怎么会发生这样的错误。
其他信息
OS: Ubuntu 12.04
Kernel Version: 3.8.0-29
Program I`m trying to compile:[AODV-UU][2]
请帮我修复它。
答案1
此文件已被移动。在您的内核中它将位于include/uapi/asm-generic/types.h
解决方案
- 更新参考
types.h
但我不确定是否可行。
或者
- 如果您有该信息,请根据其支持的内核版本编译该程序。
答案2
ARCH
在终端中将环境变量设置为x86
:export ARCH=x86
或者
将以下行添加export ARCH=x86
到 Makefile 中
答案3
当我尝试编译 USB WiFi 适配器驱动程序(Makefile
我正在修改该驱动程序以使用 Debian 为 RISC-V VisionFive 2 包含 riscv64)时,我遇到了看似相同的错误。
user@starfive:~/Documents/github/rtl88x2bu$ make
make ARCH=riscv64 CROSS_COMPILE= -C /lib/modules/5.15.0-starfive/build M=/home/user/Documents/github/rtl88x2bu modules
make[1]: Entering directory '/lib/modules/5.15.0-starfive/build'
warning: the compiler differs from the one used to build the kernel
The kernel was built by: gcc-12 (Debian 12.2.0-9) 12.2.0
You are using: gcc (Debian 12.2.0-10) 12.2.0
CC [M] /home/user/Documents/github/rtl88x2bu/core/rtw_cmd.o
In file included from /usr/src/linux-headers-6.0.0-6-common/include/linux/types.h:6,
from /home/user/Documents/github/rtl88x2bu/include/basic_types.h:75,
from /home/user/Documents/github/rtl88x2bu/include/drv_types.h:26,
from /home/user/Documents/github/rtl88x2bu/core/rtw_cmd.c:17:
/usr/src/linux-headers-6.0.0-6-common/include/uapi/linux/types.h:5:10: fatal error: asm/types.h: No such file or directory
5 | #include <asm/types.h>
| ^~~~~~~~~~~~~
compilation terminated.
make[2]: *** [/usr/src/linux-headers-6.0.0-6-common/scripts/Makefile.build:254: /home/user/Documents/github/rtl88x2bu/core/rtw_cmd.o] Error 1
make[1]: *** [/usr/src/linux-headers-6.0.0-6-common/Makefile:1876: /home/user/Documents/github/rtl88x2bu] Error 2
make[1]: Leaving directory '/lib/modules/5.15.0-starfive/build'
make: *** [Makefile:2410: modules] Error 2
user@starfive:~/Documents/github/rtl88x2bu$
types.h
我对要使用的文件进行了快速更改asm-generic/types.h
,并遇到了另一个使用asm
目录而不是的包含指令asm-generic
。
所以我撤销了所做的更改并采取了不同的策略。我创建了一个名为 的符号asm
链接asm-generic
。
user@starfive:~/Documents/github/rtl88x2bu$ cd /usr/src/linux-headers-6.0.0-6-common/include/uapi
user@starfive:/usr/src/linux-headers-6.0.0-6-common/include/uapi$ ls
Kbuild asm-generic drm linux misc mtd rdma scsi sound video xen
user@starfive:/usr/src/linux-headers-6.0.0-6-common/include/uapi$ sudo ln -s ./asm-generic ./asm
user@starfive:/usr/src/linux-headers-6.0.0-6-common/include/uapi$
然后我可以重做,make
但是我遇到了另一种用法,asm
而不是asm-generic
在不同的包含目录中。
user@starfive:~/Documents/github/rtl88x2bu$ make
make ARCH=riscv64 CROSS_COMPILE= -C /lib/modules/5.15.0-starfive/build M=/home/user/Documents/github/rtl88x2bu modules
make[1]: Entering directory '/lib/modules/5.15.0-starfive/build'
warning: the compiler differs from the one used to build the kernel
The kernel was built by: gcc-12 (Debian 12.2.0-9) 12.2.0
You are using: gcc (Debian 12.2.0-10) 12.2.0
CC [M] /home/user/Documents/github/rtl88x2bu/core/rtw_cmd.o
In file included from /usr/src/linux-headers-6.0.0-6-common/include/linux/build_bug.h:5,
from /usr/src/linux-headers-6.0.0-6-common/include/linux/container_of.h:5,
from /usr/src/linux-headers-6.0.0-6-common/include/linux/list.h:5,
from /usr/src/linux-headers-6.0.0-6-common/include/linux/module.h:12,
from /home/user/Documents/github/rtl88x2bu/include/basic_types.h:76,
from /home/user/Documents/github/rtl88x2bu/include/drv_types.h:26,
from /home/user/Documents/github/rtl88x2bu/core/rtw_cmd.c:17:
/usr/src/linux-headers-6.0.0-6-common/include/linux/compiler.h:254:10: fatal error: asm/rwonce.h: No such file or directory
254 | #include <asm/rwonce.h>
| ^~~~~~~~~~~~~~
compilation terminated.
make[2]: *** [/usr/src/linux-headers-6.0.0-6-common/scripts/Makefile.build:254: /home/user/Documents/github/rtl88x2bu/core/rtw_cmd.o] Error 1
make[1]: *** [/usr/src/linux-headers-6.0.0-6-common/Makefile:1876: /home/user/Documents/github/rtl88x2bu] Error 2
make[1]: Leaving directory '/lib/modules/5.15.0-starfive/build'
make: *** [Makefile:2410: modules] Error 2
user@starfive:~/Documents/github/rtl88x2bu$
所以我在不同的包含树中使用了相同的过程。
user@starfive:~/Documents/github/rtl88x2bu$ cd /usr/src/linux-headers-6.0.0-6-common/include
user@starfive:/usr/src/linux-headers-6.0.0-6-common/include$ ls
acpi crypto keys linux memory pcmcia rv sound uapi video
asm-generic drm kunit math-emu misc ras scsi target ufs xen
clocksource dt-bindings kvm media net rdma soc trace vdso
user@starfive:/usr/src/linux-headers-6.0.0-6-common/include$ sudo ln -s ./asm-generic ./asm
我刚刚遇到了一个错误,因为需要修改一个选项Makefile
以支持 riscv64。但是源代码似乎编译得相当好,尽管有警告。大多数警告都与大小有关,int
例如从指针转换为 int。