从源代码编译 Linux 内核时遇到问题

从源代码编译 Linux 内核时遇到问题

我正在尝试从以下位置找到的源代码树编译内核https://github.com/fio-prf/em,运行时出现以下错误make

make[1]: Nothing to be done for `all'.
make[1]: Nothing to be done for `relocs'.
  CHK     include/linux/version.h
  CHK     include/generated/utsrelease.h
  CALL    scripts/checksyscalls.sh
  CHK     include/generated/compile.h
make[3]: `arch/x86/realmode/rm/realmode.bin' is up to date.
  CC [M]  drivers/md/persistent-data/dm-btree.o
In file included from drivers/md/persistent-data/dm-btree.c:7:
drivers/md/persistent-data/dm-btree-internal.h:39: error: redefinition of ‘struct node’
make[3]: *** [drivers/md/persistent-data/dm-btree.o] Error 1
make[2]: *** [drivers/md/persistent-data] Error 2
make[1]: *** [drivers/md] Error 2
make: *** [drivers] Error 2

我将源代码树下载到/usr/src/我的机器上(正在运行CentOS 6.4)。我以前从未这样做过,而且对 C 也不是很熟悉,我不确定问题是什么。

  • 运行时出错make bzImage

    make[2]: Nothing to be done for `all'.
    make[2]: Nothing to be done for `relocs'.
      HOSTCC  scripts/unifdef
      INSTALL include/asm-generic (35 files)
      INSTALL include/drm (15 files)
      INSTALL include/linux/byteorder (2 files)
      INSTALL include/linux/caif (2 files)
      INSTALL include/linux/can (5 files)
      INSTALL include/linux/dvb (8 files)
      INSTALL include/linux/hdlc (1 file)
      INSTALL include/linux/hsi (1 file)
      INSTALL include/linux/isdn (1 file)
      INSTALL include/linux/mmc (1 file)
      INSTALL include/linux/netfilter/ipset (4 files)
    make[4]: *** No rule to make target `/usr/src/linux-3.6.0-swap/include/linux/netfilter/xt_CONNMARK.h', needed by `/usr/src/linux-3.6.0-swap/usr/include/linux/netfilter/.install'.  Stop.
    make[3]: *** [netfilter] Error 2
    make[2]: *** [linux] Error 2
    make[1]: *** [headers_install] Error 2
    make: *** [vmlinux] Error 2
    

答案1

Generally here are the steps.
Download from kernel.org
https://www.kernel.org/pub/linux/kernel/v3.x/linux-3.10.7.tar.xz
Extract the kernel
cd /usr/src/linux-3.10.7 (or whatever)
make localmodconfig
if you need to change the default settings "make menuconfig"
make bzImage && make modules && make modules_install && make install

相关内容