리눅스 커널 컴파일 오류

리눅스 커널 컴파일 오류

Linux 커널 컴파일이 처음이어서 Linux 커널을 직접 컴파일하는 것은 이번이 처음입니다(다른 TCP 혼잡 제어 알고리즘을 사용하려고 합니다).

나는 다음 단계를 따랐다.리눅스 커널을 컴파일하는 방법. 실행하려고 하면 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/. 이 문제를 해결하기 어려울 것이라고 생각합니다. 우분투를 닫고 휴식을 취하세요. 하지만 오늘 아침에 우분투를 켰는데 모든 것이 잘 작동했습니다.

관련 정보