【问题标题】:fatal error asm/bitsperlong.h No such file or directory致命错误 asm/bitsperlong.h 没有这样的文件或目录
【发布时间】:2017-03-28 06:56:30
【问题描述】:

我尝试在 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

我该如何解决这个问题?

【问题讨论】:

标签: linux compilation


【解决方案1】:

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

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2010-12-29
    • 2017-05-09
    • 2021-05-15
    • 2014-10-31
    • 2022-01-11
    • 2021-09-19
    • 2016-06-23
    相关资源
    最近更新 更多