linuxkernelcross-compilingbeagleboneblack

How do I fix gcc not found error when cross compiling the linux kernel for beaglebone black


I am trying to cross-compile the Linux kernel for the beaglebone black on Ubuntu 22.04 using the command line below:

make ARCH=arm CROSS_COMPILE=arm-linux-gnueabi- bb.org_defconfig

I get the following error:

HOSTCC  scripts/basic/fixdep
/bin/sh: 1: gcc: not found
make[2]: *** [scripts/Makefile.host:90: scripts/basic/fixdep] Error 127
make[1]: *** [Makefile:467: scripts_basic] Error 2
make: *** [Makefile:633: include/config/auto.conf.cmd] Error 2

As a result of various searches, I have verified that I have arm-linux-gnueabi-gcc in /bin:

/bin$ find . -maxdepth 1 -name "*gcc*" -print

./arm-linux-gnueabi-gcc-ranlib-11
./arm-linux-gnueabihf-gcc
./arm-linux-gnueabi-gcc-11
./arm-linux-gnueabi-gcc-nm
./arm-linux-gnueabihf-gcc-nm
./arm-linux-gnueabi-gcc-ranlib
./arm-linux-gnueabi-gcc-nm-11
./arm-linux-gnueabihf-gcc-ranlib
./arm-linux-gnueabihf-gcc-ar-11
./arm-linux-gnueabihf-gcc-ranlib-11
./arm-linux-gnueabihf-gcc-11
./arm-linux-gnueabi-gcc-ar
./arm-linux-gnueabihf-gcc-nm-11
./arm-linux-gnueabi-gcc
./arm-linux-gnueabihf-gcc-ar
./arm-linux-gnueabi-gcc-ar-11

that my path includes /bin:

echo $PATH
 /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/snap/bin 

What am I missing?


Solution

  • In short: When cross-compiling Linux kernel, you need not only a cross-compiler, but a compiler (gcc) for your host too.


    When build the Linux kernel and modules, the build system not only compiles binaries for the target platform, but also executes some programs on these binaries. These programs are shipped with the Linux kernel sources as sources, so for build these programs host compiler is needed.

    By the way, a line started with HOSTCC means that exactly host compiler is used for that operation.