linux - fatal error asm/bitsperlong.h 没有这样的文件或目录

标签 linux compilation

我尝试在 Ubuntu 14.04 上构建 Linux 模块。

但出现如下错误。

dhkim@eslee:~/Project/Linux/Hello$ make
make -C /lib/modules/3.13.0-106-generic/build M=/home/dhkim/Project/Linux/Hello modules
make[1]: Entering directory `/usr/src/linux-headers-3.13.0-106-generic'
  CC [M]  /home/dhkim/Project/Linux/Hello/hello.o
In file included from include/asm-generic/int-ll64.h:10:0,
                 from /usr/src/linux-headers-3.13.0-106-generic/arch/arm/include/asm/types.h:4,
                 from include/uapi/linux/types.h:4,
                 from include/linux/types.h:5,
                 from include/linux/init.h:5,
                 from /home/dhkim/Project/Linux/Hello/hello.c:1:
include/uapi/asm-generic/int-ll64.h:11:29: fatal error: asm/bitsperlong.h: No such file or directory
 #include <asm/bitsperlong.h>

compilation terminated.
make[2]: *** [/home/dhkim/Project/Linux/Hello/hello.o] error 1
make[1]: *** [_module_/home/dhkim/Project/Linux/Hello] error 2
make[1]: Leaving directory `/usr/src/linux-headers-3.13.0-106-generic'
make: *** [default] error 2

构建环境如下。

obj-m := hello.o
KDIR := /lib/modules/$(shell uname -r)/build
PWD := $(shell pwd)

default :
    $(MAKE) -C $(KDIR) M=$(PWD) modules

clean :
    rm -rf *.ko *.mod.* *.o 

--

dhkim@eslee:~/Project/Linux/Hello$ uname -r
3.13.0-106-generic

dhkim@eslee:/usr/include$ ls asm
a.out.h        errno.h          kvm.h        mtrr.h             prctl.h            sigcontext.h    svm.h        unistd_64.h
auxvec.h       fcntl.h          kvm_para.h   param.h            processor-flags.h  sigcontext32.h  swab.h       unistd_x32.h
bitsperlong.h  hw_breakpoint.h  ldt.h        perf_regs.h        ptrace-abi.h       siginfo.h       termbits.h   vm86.h
boot.h         hyperv.h         mce.h        poll.h             ptrace.h           signal.h        termios.h    vmx.h
bootparam.h    ioctl.h          mman.h       posix_types.h      resource.h         socket.h        types.h      vsyscall.h
byteorder.h    ioctls.h         msgbuf.h     posix_types_32.h   sembuf.h           sockios.h       ucontext.h
debugreg.h     ipcbuf.h         msr-index.h  posix_types_64.h   setup.h            stat.h          unistd.hH
e820.h         ist.h            msr.h        posix_types_x32.h  shmbuf.h           statfs.h        unistd_32.h

如何解决这个问题?

最佳答案

我注意到错误路径中出现了“arm”一词。在将系统设置为 ARM 交叉编译后,我遇到了相同的错误。如果您尝试构建普通的 x86 模块,您至少需要暂时恢复各种环境变量。

export CROSS_COMPILE=
export ARCH=x86_64 [or whatever arch you have]

关于linux - fatal error asm/bitsperlong.h 没有这样的文件或目录,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43062610/

相关文章:

c - 在 linux 上获取 NIC/以太网卡链接状态的事件

linux - Makefile 遗漏了一个看起来可用的规则

javascript - CoffeeScript - 空间问题

java - 将 .class 文件转换为 .cap JavaCard 3.0.2 Connected Edition

code-generation - Java JVM/.NET CLR 的代码生成

linux - 如何仅在命令上获取数据

linux - 在接收到与 xinetd 的传入连接时执行脚本

c++ - 直接读取 pthread 互斥体的所有者字段是否安全?

linux - 如何在 Bash 的算术表达式中使用字符串

java - 编译 Ubuntu Touch 无规则使目标为 "APPS/../src/R.stamp"