致命错误asm / bitsperlong.h没有这样的文件或目录

时间:2017-03-28 06:56:30

标签: 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

我该如何解决这个问题?

1 个答案:

答案 0 :(得分:0)

我注意到&#34; arm&#34;出现在错误路径中。在我将系统设置为ARM的交叉编译之后,我遇到了相同的错误。如果您正在尝试构建普通的x86模块,则至少需要暂时还原各种环境变量。

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