Linuxカーネルのコンパイルエラー

Linuxカーネルのコンパイルエラー

Linuxカーネルのコンパイルが初めてで、Linuxカーネルを直接コンパイルするのは今回が初めてです(他のTCP輻輳制御アルゴリズムを使用しようとしています)。

私は次のステップに従いました。Linuxカーネルをコンパイルする方法。実行しようとすると、make次のエラーが発生します。

✘ XPS-13-9360  ~/linux_compile/linux-5.1.18  make                     
  CALL    scripts/checksyscalls.sh
  CALL    scripts/atomic/check-atomics.sh
  DESCEND  objtool
  CC       /home/soar/linux_compile/linux-5.1.18/tools/objtool/arch/x86/decode.o
In file included from /usr/include/gelf.h:32:0,
                 from arch/x86/../../elf.h:22,
                 from arch/x86/decode.c:26:
/usr/include/libelf.h:46:4: error: unknown type name ‘Elf32_Word’
    Elf32_Word   ch_type;        /* Compression format.  */
    ^~~~~~~~~~
/usr/include/libelf.h:47:4: error: unknown type name ‘Elf32_Word’
    Elf32_Word   ch_size;        /* Uncompressed data size.  */
    ^~~~~~~~~~
/usr/include/libelf.h:48:4: error: unknown type name ‘Elf32_Word’
    Elf32_Word   ch_addralign;   /* Uncompressed data alignment.  */
    ^~~~~~~~~~
/usr/include/libelf.h:53:4: error: unknown type name ‘Elf64_Word’
    Elf64_Word   ch_type;        /* Compression format.  */
    ^~~~~~~~~~
/usr/include/libelf.h:54:4: error: unknown type name ‘Elf64_Word’
    Elf64_Word   ch_reserved;
    ^~~~~~~~~~
/usr/include/libelf.h:55:4: error: unknown type name ‘Elf64_Xword’
    Elf64_Xword  ch_size;        /* Uncompressed data size.  */
    ^~~~~~~~~~~
/usr/include/libelf.h:56:4: error: unknown type name ‘Elf64_Xword’
    Elf64_Xword  ch_addralign;   /* Uncompressed data alignment.  */
    ^~~~~~~~~~~
/usr/include/libelf.h:253:8: error: unknown type name ‘Elf32_Ehdr’
 extern Elf32_Ehdr *elf32_getehdr (Elf *__elf);
        ^~~~~~~~~~
/usr/include/libelf.h:255:8: error: unknown type name ‘Elf64_Ehdr’
 extern Elf64_Ehdr *elf64_getehdr (Elf *__elf);
        ^~~~~~~~~~
/usr/include/libelf.h:258:8: error: unknown type name ‘Elf32_Ehdr’
 extern Elf32_Ehdr *elf32_newehdr (Elf *__elf);
        ^~~~~~~~~~
/usr/include/libelf.h:260:8: error: unknown type name ‘Elf64_Ehdr’
 extern Elf64_Ehdr *elf64_newehdr (Elf *__elf);
        ^~~~~~~~~~
/usr/include/libelf.h:269:8: error: unknown type name ‘Elf32_Phdr’
 extern Elf32_Phdr *elf32_getphdr (Elf *__elf);
        ^~~~~~~~~~
/usr/include/libelf.h:271:8: error: unknown type name ‘Elf64_Phdr’
 extern Elf64_Phdr *elf64_getphdr (Elf *__elf);
        ^~~~~~~~~~
/usr/include/libelf.h:274:8: error: unknown type name ‘Elf32_Phdr’
 extern Elf32_Phdr *elf32_newphdr (Elf *__elf, size_t __cnt);
        ^~~~~~~~~~
/usr/include/libelf.h:276:8: error: unknown type name ‘Elf64_Phdr’
 extern Elf64_Phdr *elf64_newphdr (Elf *__elf, size_t __cnt);
        ^~~~~~~~~~
/usr/include/libelf.h:283:43: error: unknown type name ‘Elf32_Off’; did you mean ‘Elf32_Chdr’?
 extern Elf_Scn *elf32_offscn (Elf *__elf, Elf32_Off __offset);
                                           ^~~~~~~~~
                                           Elf32_Chdr
/usr/include/libelf.h:285:43: error: unknown type name ‘Elf64_Off’; did you mean ‘Elf64_Chdr’?
 extern Elf_Scn *elf64_offscn (Elf *__elf, Elf64_Off __offset);
                                           ^~~~~~~~~
                                           Elf64_Chdr
/usr/include/libelf.h:325:8: error: unknown type name ‘Elf32_Shdr’
 extern Elf32_Shdr *elf32_getshdr (Elf_Scn *__scn);
        ^~~~~~~~~~
/usr/include/libelf.h:327:8: error: unknown type name ‘Elf64_Shdr’
 extern Elf64_Shdr *elf64_getshdr (Elf_Scn *__scn);
        ^~~~~~~~~~
In file included from arch/x86/../../elf.h:22:0,
                 from arch/x86/decode.c:26:
/usr/include/gelf.h:44:9: error: unknown type name ‘Elf64_Half’
 typedef Elf64_Half GElf_Half;
         ^~~~~~~~~~
/usr/include/gelf.h:47:9: error: unknown type name ‘Elf64_Word’
 typedef Elf64_Word GElf_Word;
         ^~~~~~~~~~
/usr/include/gelf.h:48:9: error: unknown type name ‘Elf64_Sword’
 typedef Elf64_Sword GElf_Sword;
         ^~~~~~~~~~~
/usr/include/gelf.h:51:9: error: unknown type name ‘Elf64_Xword’
 typedef Elf64_Xword GElf_Xword;
         ^~~~~~~~~~~
/usr/include/gelf.h:52:9: error: unknown type name ‘Elf64_Sxword’
 typedef Elf64_Sxword GElf_Sxword;
         ^~~~~~~~~~~~
/usr/include/gelf.h:55:9: error: unknown type name ‘Elf64_Addr’
 typedef Elf64_Addr GElf_Addr;
         ^~~~~~~~~~
/usr/include/gelf.h:58:9: error: unknown type name ‘Elf64_Off’
 typedef Elf64_Off GElf_Off;
         ^~~~~~~~~
/usr/include/gelf.h:62:9: error: unknown type name ‘Elf64_Ehdr’
 typedef Elf64_Ehdr GElf_Ehdr;
         ^~~~~~~~~~
/usr/include/gelf.h:65:9: error: unknown type name ‘Elf64_Shdr’
 typedef Elf64_Shdr GElf_Shdr;
         ^~~~~~~~~~
/usr/include/gelf.h:70:9: error: unknown type name ‘Elf64_Section’
 typedef Elf64_Section GElf_Section;
         ^~~~~~~~~~~~~
/usr/include/gelf.h:73:9: error: unknown type name ‘Elf64_Sym’
 typedef Elf64_Sym GElf_Sym;
         ^~~~~~~~~
/usr/include/gelf.h:77:9: error: unknown type name ‘Elf64_Syminfo’
 typedef Elf64_Syminfo GElf_Syminfo;
         ^~~~~~~~~~~~~
/usr/include/gelf.h:80:9: error: unknown type name ‘Elf64_Rel’
 typedef Elf64_Rel GElf_Rel;
         ^~~~~~~~~
/usr/include/gelf.h:83:9: error: unknown type name ‘Elf64_Rela’
 typedef Elf64_Rela GElf_Rela;
         ^~~~~~~~~~
/usr/include/gelf.h:86:9: error: unknown type name ‘Elf64_Phdr’
 typedef Elf64_Phdr GElf_Phdr;
         ^~~~~~~~~~
/usr/include/gelf.h:92:9: error: unknown type name ‘Elf64_Dyn’
 typedef Elf64_Dyn GElf_Dyn;
         ^~~~~~~~~
/usr/include/gelf.h:96:9: error: unknown type name ‘Elf64_Verdef’
 typedef Elf64_Verdef GElf_Verdef;
         ^~~~~~~~~~~~
/usr/include/gelf.h:99:9: error: unknown type name ‘Elf64_Verdaux’
 typedef Elf64_Verdaux GElf_Verdaux;
         ^~~~~~~~~~~~~
/usr/include/gelf.h:102:9: error: unknown type name ‘Elf64_Verneed’
 typedef Elf64_Verneed GElf_Verneed;
         ^~~~~~~~~~~~~
/usr/include/gelf.h:105:9: error: unknown type name ‘Elf64_Vernaux’
 typedef Elf64_Vernaux GElf_Vernaux;
         ^~~~~~~~~~~~~
/usr/include/gelf.h:109:9: error: unknown type name ‘Elf64_Versym’
 typedef Elf64_Versym GElf_Versym;
         ^~~~~~~~~~~~
/usr/include/gelf.h:113:9: error: unknown type name ‘Elf64_auxv_t’
 typedef Elf64_auxv_t GElf_auxv_t;
         ^~~~~~~~~~~~
/usr/include/gelf.h:117:9: error: unknown type name ‘Elf64_Nhdr’
 typedef Elf64_Nhdr GElf_Nhdr;
         ^~~~~~~~~~
/usr/include/gelf.h:121:9: error: unknown type name ‘Elf64_Move’
 typedef Elf64_Move GElf_Move;
         ^~~~~~~~~~
/usr/include/gelf.h:125:9: error: unknown type name ‘Elf64_Lib’
 typedef Elf64_Lib GElf_Lib;
         ^~~~~~~~~
/usr/include/gelf.h:232:8: error: unknown type name ‘Elf32_Word’; did you mean ‘GElf_Word’?
        Elf32_Word *__xshndx);
        ^~~~~~~~~~
        GElf_Word
/usr/include/gelf.h:238:6: error: unknown type name ‘Elf32_Word’; did you mean ‘GElf_Word’?
      Elf32_Word __xshndx);
      ^~~~~~~~~~
      GElf_Word
arch/x86/decode.c: In function ‘is_x86_64’:
arch/x86/decode.c:43:19: error: request for member ‘e_machine’ in something not a structure or union
  switch (elf->ehdr.e_machine) {
                   ^
arch/x86/decode.c:44:7: error: ‘EM_X86_64’ undeclared (first use in this function); did you mean ‘is_x86_64’?
  case EM_X86_64:
       ^~~~~~~~~
       is_x86_64
arch/x86/decode.c:44:7: note: each undeclared identifier is reported only once for each function it appears in
arch/x86/decode.c:46:7: error: ‘EM_386’ undeclared (first use in this function); did you mean ‘EM_X86_64’?
  case EM_386:
       ^~~~~~
       EM_X86_64
In file included from arch/x86/decode.c:28:0:
arch/x86/decode.c:49:51: error: request for member ‘e_machine’ in something not a structure or union
   WARN("unexpected ELF machine type %d", elf->ehdr.e_machine);
                                                   ^
arch/x86/../../warn.h:58:14: note: in definition of macro ‘WARN’
   objname, ##__VA_ARGS__)
              ^~~~~~~~~~~
arch/x86/decode.c:52:1: error: control reaches end of non-void function [-Werror=return-type]
 }
 ^
cc1: all warnings being treated as errors
mv: cannot stat '/home/soar/linux_compile/linux-5.1.18/tools/objtool/arch/x86/.decode.o.tmp': No such file or directory
/home/soar/linux_compile/linux-5.1.18/tools/build/Makefile.build:96: recipe for target '/home/soar/linux_compile/linux-5.1.18/tools/objtool/arch/x86/decode.o' failed
make[4]: *** [/home/soar/linux_compile/linux-5.1.18/tools/objtool/arch/x86/decode.o] Error 1
/home/soar/linux_compile/linux-5.1.18/tools/build/Makefile.build:139: recipe for target 'arch/x86' failed
make[3]: *** [arch/x86] Error 2
Makefile:50: recipe for target '/home/soar/linux_compile/linux-5.1.18/tools/objtool/objtool-in.o' failed
make[2]: *** [/home/soar/linux_compile/linux-5.1.18/tools/objtool/objtool-in.o] Error 2
Makefile:66: recipe for target 'objtool' failed
make[1]: *** [objtool] Error 2
Makefile:1699: recipe for target 'tools/objtool' failed
make: *** [tools/objtool] Error 2

libelf.hから: ここに画像の説明を入力してください。 そしてelf.hここに画像の説明を入力してください。 それから私は見つけました。以前に報告されたことしかし、まだ解決策はありません。どうですか?

ベストアンサー1

実はこれは私が直接思い出したんです。コンパイラが私が考えるヘッダを見つけることができないようです。envコマンドを使用すると、CPATHが/usr/include/butにないため、次のように/home/user/.local/include:$CPATHCPATHをに変更しました。/usr/include/クレイマー、しかし、まだ動作しません。 envは、CPATHがすでにあることを示しています/usr/include/。この問題を解決するのは難しいと思います。 Ubuntuを閉じてリラックスしてください。しかし、今朝Ubuntuをオンにしましたが、すべてがうまくいきました。

おすすめ記事