modpost.h:12:23: 致命的なエラー: elfconfig.h: そのファイルまたはディレクトリがありません。

modpost.h:12:23: 致命的なエラー: elfconfig.h: そのファイルまたはディレクトリがありません。

私はUbuntuを実行しています:

#lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 12.04.4 LTS
Release:    12.04
Codename:   precise
Kernel info:

3.8.0-38-generic #56~precise1-Ubuntu SMP Thu Mar 13 16:23:47 UTC 2014 i686 i686 i386 GNU/Linux

私が持っているソースは次のとおりです。 Linux-lts-raring-3.8.0

最初のドライバを作成しようとすると、次のエラーが発生します。

make -C /usr/linux-lts-raring-3.8.0 SUBDIRS=/home/drdr/Documents/drivers/first_driver modules
make[1]: Entering directory `/usr/linux-lts-raring-3.8.0'

  WARNING: Symbol version dump /usr/linux-lts-raring-3.8.0/Module.symvers
           is missing; modules will have no dependencies and modversions.

  Building modules, stage 2.
  MODPOST 1 modules
/bin/sh: 1: scripts/mod/modpost: not found
make[2]: *** [__modpost] Error 127
make[1]: *** [modules] Error 2
make[1]: Leaving directory `/usr/linux-lts-raring-3.8.0'
make: *** [default] Error 2

次に、ソースディレクトリのscripts / mod /に移動してmakeと入力します。

root@drdr:/usr/linux-lts-raring-3.8.0/scripts/mod# make modpost
cc     modpost.c   -o modpost
In file included from modpost.c:18:0:
modpost.h:12:23: fatal error: elfconfig.h: No such file or directory
compilation terminated.
make: *** [modpost] Error 1

修正する 関連ファイルmk_elfconfig.cが見つかりました。 elfconfig.hを生成する方法はありますか?

root@drdr:/usr/linux-lts-raring-3.8.0/scripts/mod# ls -ld mk_elfconfig.c 
-rw-r--r-- 1 root root 1234 Feb 19  2013 mk_elfconfig.c

このエラーが発生するのはなぜですか?ソースバージョンと実行バージョンが同じだと思います。

ドライバのMakefileとソースコードが提供されています。ここ

修正する /bootの設定をソースコードに.configにコピーした後:コピーしました。

root@drdr:/home/drdr/Documents/drivers/linux-lts-raring-3.8.0#make oldconfig 
scripts/kconfig/conf --oldconfig Kconfig
#
# configuration written to .config
#

root@drdr:/home/drdr/Documents/drivers/linux-lts-raring-3.8.0# make prepare
scripts/kconfig/conf --silentoldconfig Kconfig
  SYSHDR  arch/x86/syscalls/../include/generated/uapi/asm/unistd_32.h
  SYSHDR  arch/x86/syscalls/../include/generated/uapi/asm/unistd_64.h
  SYSHDR  arch/x86/syscalls/../include/generated/uapi/asm/unistd_x32.h
  SYSTBL  arch/x86/syscalls/../include/generated/asm/syscalls_32.h
  HOSTCC  arch/x86/tools/relocs
  WRAP    arch/x86/include/generated/asm/clkdev.h
  CHK     include/generated/uapi/linux/version.h
  UPD     include/generated/uapi/linux/version.h
  CHK     include/generated/utsrelease.h
  UPD     include/generated/utsrelease.h
  CC      kernel/bounds.s
  GEN     include/generated/bounds.h
  CC      arch/x86/kernel/asm-offsets.s
  GEN     include/generated/asm-offsets.h
  CALL    scripts/checksyscalls.sh
root@drdr:/home/drd/Documents/drivers/linux-lts-raring-3.8.0# 

ただし、ドライバをコンパイルすると、同じエラーが発生します。

root@drdr:/home/drdr/Documents/drivers/first_driver# make
make -C /usr/linux-lts-raring-3.8.0 SUBDIRS=/home/drdr/Documents/drivers/first_driver modules
make[1]: Entering directory `/usr/linux-lts-raring-3.8.0'

  WARNING: Symbol version dump /usr/linux-lts-raring-3.8.0/Module.symvers
           is missing; modules will have no dependencies and modversions.

  Building modules, stage 2.
  MODPOST 1 modules
/bin/sh: 1: scripts/mod/modpost: not found
make[2]: *** [__modpost] Error 127
make[1]: *** [modules] Error 2
make[1]: Leaving directory `/usr/linux-lts-raring-3.8.0'
make: *** [default] Error 2 

ベストアンサー1

解凍したものが正確に何であるかはわかりませんが、/usr/linux-lts-raring-3.8.0次のようになります。

  • これはあなたに必要なものではないかもしれません。
  • 場所は本当に変です。直接入ってはいけません/usr

カーネルモジュールをコンパイルするには、同じ構成でカーネルをコンパイルして生成されたヘッダーと追加のファイルだけが必要です。バラよりモジュールを読み込めません: module_layout シンボルのバージョンに同意しません。より完全な説明のために。

これを削除し/usr/linux-lts-raring-3.8.0、実行中のカーネルに対応するカーネルヘッダパッケージをインストールします。たとえば、実行中のカーネルがそのlinux-image-3.8.0-38-genericパッケージで提供されている場合は、そのlinux-headers-3.8.0-38-genericパッケージをインストールします。

特定のDebian / Ubuntu / ...カーネルバージョン(たとえば)用のモジュールをコンパイルするには、モジュールlinux-headers-3.8.0-38-genericディレクトリに移動して次のコマンドを実行します。

make -C /usr/src/linux-headers-3.8.0-38-generic M=$PWD

実行中のカーネル用にモジュールをコンパイルするには、適切なカーネルヘッダパッケージがインストールされ実行されていることを確認してください。

make -C /lib/modules/`uname -r`/build M=$PWD

私は読書をお勧めしますkbuild/modules.ttカーネル文書から。

おすすめ記事