Yesterday compiled a Linux kernel source code, encountered some problems, today I encountered problems and solutions to share to everyone. Hope can help to the people who need it.
1) Check if the appropriate package is installed (the "Development Tools" package, "Compatibility Libraries" and "Development and Creative Workstation", which I installed only the first time I compiled Not installed)
[email protected] yum.repos.d]# yum Groups list #查看包组列表Loaded plugins:fastestmirror, Langpacksthere is no installed gro UPS file. Maybe Run:yum groups mark convert (see Mans yum) Loading mirror speeds from cached hostfileavailable environment groups:
minimal Install Compute Node Infrastructure server File and Print server Basic Web server Virtualization Host Server with GUI GNOME Desktop KDE Plasma Workspaces Development and Creative Workstationavailable Groups: compatibility Libraries Console Internet tools Development Tools Graphical administration Tools Legacy UNIX compatibility scientific support Security Tools Smart Card Support System Administration Tools System Managementdone
2) Download the source code from the https://www.kernel.org/website need to compile the kernel.
Download directly here using the wget command
[Email protected] yum.repos.d]# cd/root #切换到root目录 [[email protected] ~]# wget Https://cdn.kernel.org/pub/linux/kernel /V4.X/TESTING/LINUX-4.7-RC7.TAR.XZ//Use wget to download files--2016-07-11 09:59:34-- https://cdn.kernel.org/pub/linux/ Kernel/v4.x/testing/linux-4.7-rc7.tar.xzresolving cdn.kernel.org (cdn.kernel.org) ... 151.101.88.69Connecting to Cdn.kernel.org (cdn.kernel.org) |151.101.88.69|:443 ... Connected. HTTP request sent, awaiting response ... oklength:90401360 (86M) [application/x-xz]saving to: ' Linux-4.7-rc7.tar.xz ' 100%[=============================== ====================================================>] 90,401,360 392kb/s in 6m 35s 2016-07-11 10:06:10 ( 223 kb/s)-' linux-4.7-rc7.tar.xz ' saved [90401360/90401360][[email protected] ~]# ls-l | grep linux #查看下载的文件-rw-r--r--. 1 root root 90401360 Jul 23:41 linux-4.7-rc7.tar.xz
3) Unzip the file and create the symbolic link file
TAR-XF linux-4.7-rc7.tar.xz -c/usr/src/#解压缩到指定目录 [[email protected] ~]# lsanaconda-ks.cfg Documents Initial-setup-ks.cfg Music public videosdesktop Downloads linux-4.7-rc7.tar.xz Pictures templates[[email protected] ~]# cd/usr/src/#进入文件目录 [[email protected] src]# lsdebug Kernels Linux-4.7-rc7[[email protected] src]# ln-sv linux-4.7-rc7/linux #创建符号链接 ' Linux ', ' linux-4.7-rc7/' [[Email protected ] src]# ls #查看debug kernels linux Linux-4.7-rc7
4) Create a. config file
[[email protected] linux]# lsarch COPYING documentation FS IPC kernel maintainers net Samples Sound virtblock CREDITS drivers include Kbuild Lib Makefile README Scripts toolscerts crypto firmware init Kconfig linux mm reporting-bugs Security usr[[email protected] linux]# make Menuconfig HOSTCC scripts/ BASIC/FIXDEP HOSTCC scripts/kconfig/mconf.oin file included from scripts/kconfig/mconf.c:23:0:scripts/ Kconfig/lxdialog/dialog.h:38:20:fatal error:curses.h:no such file or directory #include curses_loc ^compilation t ERMINATED.MAKE[1]: * * * [SCRIPTS/KCONFIG/MCONF.O] Error 1make: * * [Menuconfig] Error 2
The report is wrong here. Tip curses.h This file cannot be found.
[[email protected] linux]# yum Search curses #从yum源查找curses相关的包, configure the local Yum source to see my last blog post. Loaded plugins:fastestmirror, langpacksloading mirror speeds from cached hostfile==================================== ================ N/S matched:curses ====================================================ncurses.x86_64:ncurses Support utilitiesncurses-devel.i686:development files for the ncurses libraryncurses-devel.x86_64:development files fo R the ncurses libraryncurses-libs.i686:ncurses librariesncurses-libs.x86_64:ncurses librariesncurses-static.i686:st atic libraries for the ncurses libraryncurses-static.x86_64:static libraries for the ncurses libraryocaml-curses.x86_64 : OCaml bindings for ncursesocaml-curses-devel.x86_64:development files for ocaml-cursesnetworkmanager-tui.x86_64:net WorkManager curses-based uincurses-base.noarch:descriptions of Common terminalsncurses-term.noarch:terminal Descriptions Name and summary matches only, use ' Search all ' for everything. [[EmAil protected] linux]# yum install ncurses #安装ncursesLoaded plugins:fastestmirror, langpacksloading mirror speeds From cached Hostfilepackage ncurses-5.9-13.20130511.el7.x86_64 already installed and latest versionnothing to do[[email& Nbsp;protected] linux]# yum install ncurses-devel #安装ncurses-develloaded plugins:fastestmirror, langpacksloading Mirror speeds from cached hostfileresolving dependencies--> Running transaction Check---> Package Ncurses-devel.x86_64 0:5.9-13.20130511.el7 'll be installed--> finished Dependency resolutiondependencies Resolved =============================================================================================================== ============== Package Arch Version Repository size========================================================================================================== ===================installing:ncurses-devel x86_5.9-13.20130511.el7 Localcdrom 713 Ktransaction summary============== =============================================================================================================== Install 1 packagetotal Download size:713 kinstalled size:2.1 MIs This ok [y/d/n]: ydownloading packages:running Transac tion checkrunning transaction testtransaction Test succeededrunning transaction Installing: ncurses-devel-5.9-13.20130511.el7.x86_64 1/1 Verifying : ncurses-devel-5.9-13.20130511.el7.x86_64 1/1 installed : ncurses-devel.x86_64 0:5.9-13.20130511.el7 complete!
Once again make menuconfig This command, the following character interface appears, and we can configure the kernel on this interface. We are here for the second time using make menuconfig, we need to run: Makemrproper to clear the previous configuration, go back to the default configuration, and then run: Makemenuconfig generate the. config file This tool allows you to set kernel configuration parameters.
4) Execute make command
[[email protected] linux]# make HOSTCC scripts/kconfig/conf.o hostld scripts/kconfig/confscripts/kconfig/conf- -silentoldconfig Kconfig systbl arch/x86/entry/syscalls/. /.. /include/generated/asm/syscalls_32.h Syshdr arch/x86/entry/syscalls/. /.. /include/generated/asm/unistd_32_ia32.h Syshdr arch/x86/entry/syscalls/. /.. /include/generated/asm/unistd_64_x32.h systbl arch/x86/entry/syscalls/. /.. /include/generated/asm/syscalls_64.h hypercalls arch/x86/entry/syscalls/. /.. /include/generated/asm/xen-hypercalls.h Syshdr arch/x86/entry/syscalls/. /.. /include/generated/uapi/asm/unistd_32.h Syshdr arch/x86/entry/syscalls/. /.. /include/generated/uapi/asm/unistd_64.h Syshdr arch/x86/entry/syscalls/. /.. /include/generated/uapi/asm/unistd_x32.h HOSTCC scripts/basic/bin2c HOSTCC arch/x86/tools/relocs_32.o HOSTCC arch/x8 6/TOOLS/RELOCS_64.O HOSTCC arch/x86/tools/relocs_common.o hostld arch/x86/tools/relocs CHK include/config/kernel. Release UPD include/confIg/kernel.release Wrap Arch/x86/include/generated/asm/clkdev.h Wrap arch/x86/include/generated/asm/cputime.h Wrap Arch/x86/include/generated/asm/dma-contiguous.h Wrap Arch/x86/include/generated/asm/early_ioremap.h Wrap arch/ X86/include/generated/asm/mcs_spinlock.h WRAP arch/x86/include/generated/asm/mm-arch-hooks.h CHK include/generate D/uapi/linux/version.h upd include/generated/uapi/linux/version.h CHK include/generated/utsrelease.h UPD in Clude/generated/utsrelease.h CC arch/x86/purgatory/purgatory.o as arch/x86/purgatory/stack.o as Arch/x86 /PURGATORY/SETUP-X86_64.O cc ARCH/X86/PURGATORY/SHA256.O as arch/x86/purgatory/entry64.o cc Arch/x86/pur GATORY/STRING.O LD arch/x86/purgatory/purgatory.ro bin2c arch/x86/purgatory/kexec-purgatory.c CC Kernel/bou NDS.S chk include/generated/bounds.h upd include/generated/bounds.h CHK include/generated/timeconst.h upd Include/generated/tiMeconst.h CC arch/x86/kernel/asm-offsets.s CHK include/generated/asm-offsets.h UPD include/generated/asm-o Ffsets.h call scripts/checksyscalls.sh HOSTCC scripts/genksyms/genksyms.o SHIPPED scripts/genksyms/parse.tab.c HOS TCC scripts/genksyms/parse.tab.o SHIPPED scripts/genksyms/lex.lex.c SHIPPED scripts/genksyms/keywords.hash.c SHIPPED Scripts/genksyms/parse.tab.h HOSTCC scripts/genksyms/lex.lex.o hostld scripts/genksyms/genksyms CC scripts/mod/e MPTY.O HOSTCC scripts/mod/mk_elfconfig mkelf scripts/mod/elfconfig.h HOSTCC scripts/mod/modpost.o CC scripts/ MOD/DEVICETABLE-OFFSETS.S GEN scripts/mod/devicetable-offsets.h HOSTCC scripts/mod/file2alias.o HOSTCC scripts/mo D/SUMVERSION.O hostld scripts/mod/modpost HOSTCC scripts/selinux/genheaders/genheaders HOSTCC SCRIPTS/SELINUX/MDP/MD P HOSTCC scripts/kallsyms HOSTCC scripts/pnmtologo hostcc scripts/conmakehash HOSTCC scripts/recordmcount HOSTCC Scripts/sortextable HOSTCC Scripts/asn1_compiler HOSTCC scripts/sign-filescripts/sign-file.c:25:30:fatal error:openssl/opensslv.h:no such F Ile or directory #include <openssl/opensslv.h> ^
The above error, only found that the original compilation environment package is not installed.
Execute the following command to install the package
[email protected] linux]# yum groups listloaded Plugins:fastestmirror, Langpacksthere is no installed groups file. Maybe Run:yum groups mark convert (see Mans yum) Loading mirror speeds from cached hostfileavailable environment groups:
minimal Install Compute Node Infrastructure server File and Print server Basic Web server Virtualization Host Server with GUI GNOME Desktop KDE Plasma Workspaces Development and Creative Workstationavailable Groups: compatibility Libraries Console Internet tools Development Tools Graphical administration Tools Legacy UNIX compatibility scientific support Security Tools Smart Card support System Administration Tools
5) do clean and make
[email protected] linux]# make clean . Clean arch/x86/purgatory clean arch/x86/tools Clean
6) Execute Make Modules_install
7) Execute make install
8) Restart the computer to choose the newly compiled Linux.
CENTOS7 compiling Linux kernel source code