Reputation: 73
I download Linux kernel source code, successfully compiled it and run it with BusyBox in QEMU.
Because of BusyBox, I can use some frequently-used tools, such as vi
,ls
,cp
,cat
, etc.
But when I try to compile a simple "hello world" C/C++ program, I get gcc: not found
.
In addition, I can't make
a new Linux module by make -C /lib/modules/$(shell uname -r)/build/ M=$(PWD) modules
inside QEMU.
I googled a lot, still can't figure it out.
So my question is: how can I install common developer tools like gcc
, make
, etc. inside my bare-bones QEMU VM that is running my custom Linux kernel (and not a standard distribution)?
Upvotes: 0
Views: 1079
Reputation: 69522
I see that you are trying to compile some program (or module) to use it inside your QEMU machine, but you do not have a compiler toolchain installed in the machine itself. You have a couple of options:
Probably the easiest: since you already compiled the kernel that you are using for QEMU externally (in your host machine), you can easily also compile anything else this way. For modules, just pointing make
to the same kernel source directory where you built the VM kernel should suffice. Once compiled you can then copy them inside the VM disk/image like you did for busybox.
You can download and compile your own GCC from source (always on the host), and then install it inside the QEMU virtual machine. This is usually done by mounting the VM disk (QEMU image or whatever you are using) somewhere (e.g. /mnt/my-qemu-disk
) and then configuring GCC with --prefix=/mnt/my-qemu-disk/usr/local
, building and installing it with make install
. This and other stuff is explained in this documentation page.
Once you have GCC installed inside the machine, you should be able to use it as you normally do. You can now use it to compile GNU Make inside the VM, or you can just compile outside in the same way.
For complex stuff like building kernel modules you will probably also need to build and install GNU binutils in the machine, again either from the inside with the GCC you just installed or from the outside.
Upvotes: 2