我已经花了好几个小时从我的MacBook Pro重新编译https://github.com/torvalds/linux的Linux内核,最后仍然卡住了。很难找到一个教程来了解如何重新编译它,标题缺失,bla bla bla。
PS:我尝试了第一个adding a syscall
网站,因为这是我最初想要做的事情。
刚开始时,我得到了.config not found
。
*** Configuration file ".config" not found!
***
*** Please run some configurator (e.g. "make oldconfig" or
*** "make menuconfig" or "make xconfig").
***
make[3]: *** [silentoldconfig] Error 1
make[2]: *** [silentoldconfig] Error 2
make[1]: *** No rule to make target `include/config/auto.conf', needed by`include/config/kernel.release'. Stop.
与某些网络链接不同,使用的配置文件不存在或其他错误,所以我从.config
创建新的"make menuconfig"
(作为一些答案,网络)。
然后,我再次尝试编译。我尝试了一些命令:
emixam23@Maximes-MBP:~/Workspace/linux-kernel$ make
getconf: no such configuration parameter `LFS_CFLAGS'
getconf: no such configuration parameter `LFS_LDFLAGS'
getconf: no such configuration parameter `LFS_LIBS'
/bin/sh: scripts/basic/modules.order: Permission denied
make[1]: *** [scripts/basic/modules.order] Error 1
make: *** [scripts_basic] Error 2
emixam23@Maximes-MBP:~/Workspace/linux-kernel$ sudo make
Password:
getconf: no such configuration parameter `LFS_CFLAGS'
getconf: no such configuration parameter `LFS_LDFLAGS'
getconf: no such configuration parameter `LFS_LIBS'
HOSTCC arch/x86/tools/relocs_32.o
In file included from arch/x86/tools/relocs_32.c:2:
arch/x86/tools/relocs.h:13:10: fatal error: 'elf.h' file not found
#include <elf.h>
^~~~~~~
1 error generated.
make[1]: *** [arch/x86/tools/relocs_32.o] Error 1
make: *** [archscripts] Error 2
之后,我开始搜索错误是来自我的make
命令,我发现了这个:
emixam23@Maximes-MBP:~/Workspace/linux-kernel$ sudo make -j 4 && sudo make modules_install -j 4 && sudo make install -j 4
getconf: no such configuration parameter `LFS_CFLAGS'
getconf: no such configuration parameter `LFS_LDFLAGS'
getconf: no such configuration parameter `LFS_LIBS'
CHK include/config/kernel.release
CHK include/generated/uapi/linux/version.h
CHK include/generated/utsrelease.h
HOSTCC arch/x86/tools/relocs_32.o
HOSTCC arch/x86/tools/relocs_64.o
HOSTCC arch/x86/tools/relocs_common.o
In file included from arch/x86/tools/relocs_common.c:2:
arch/x86/tools/relocs.h:13:10: fatal error: 'elf.h' file not found
#include <elf.h>
^~~~~~~
In file included from arch/x86/tools/relocs_32.c:2:
arch/x86/tools/relocs.h:13:10: fatal error: 'elf.h' file not found
#include <elf.h>
^~~~~~~
In file included from arch/x86/tools/relocs_64.c:2:
arch/x86/tools/relocs.h:13:10: fatal error: 'elf.h' file not found
#include <elf.h>
^~~~~~~
1 error generated.
make[1]: *** [arch/x86/tools/relocs_common.o] Error 1
make[1]: *** Waiting for unfinished jobs....
1 error generated.
1 error generated.
make[1]: *** [arch/x86/tools/relocs_32.o] Error 1
make[1]: *** [arch/x86/tools/relocs_64.o] Error 1
make: *** [archscripts] Error 2
make: INTERNAL: Exiting with 5 jobserver tokens available; should be 4!
所以,基于我得到的错误,我搜索了<elf.h>
,这似乎与Android有关。对我来说,它没有任何联系,我的意思是,我觉得这样。
问题是,我刚刚下载了一个Linux内核(Torvalds),我添加了我的系统调用,现在我正在尝试重新编译它并将其与vagrant一起使用。就是这样。为什么它看起来如此复杂?我会说实话,我觉得完全迷失了......你有没有想过我是否对,但我只是想念一些东西,或者我完全没有好的方法?
我在MacBook Pro上工作:
MacBook Pro(Retina,15英寸,2015年中)
- macOS High Sierra
- 版本10.13.1
感谢任何提示/帮助
最高
PS:编辑1:添加我的修改: https://github.com/Emixam23/linux-kernel/commit/d7d7b66cc6513e7b69fd2122b880c259628c438a
我找到了一个流浪汉的解决方法:)使用vragrant,您可以从Mac OS重新编译内核。您只需要vagrant init
然后将自己连接到流浪的VM vagrant ssh
。进入流浪汉VM后,运行cd /
,您将到达机器的根目录,这也是您创建VM的地方,因此您可以从Mac OS执行任何操作并从终端{{ 1}}:)
答案 0 :(得分:0)
检查您的工具链。它不仅仅是android的东西。 https://linux.die.net/man/5/elf。 如果你喜欢被挑战,请继续。因为这不会是直截了当的。 如果你的任务只是编译代码使用虚拟机/其他linux机器它会更快。 但是如果你很想知道事情是如何运作的,并且让他们在Mac上工作以便在没有虚拟机的情况下进行未来的编译。然后继续。添加那些头文件。在/ usr / include中按this