1 Installation instructions for kvmtool 2--------------------------------------- 3 4========================================================================== 5For the impatient: 6Just typing "make" should do the trick most of the times. 7You will get a binary called "lkvm" which is self-contained. 8No extra libraries or files need to be installed. 9========================================================================== 10 11"make install" will copy the compiled file into $HOME/bin, this can be 12changed by providing "prefix=" on the make command-line. DESTDIR will be 13honoured. 14 15Prerequisites 16-------------- 17For compilation you will need a recent GNU tool chain (binutils, gcc, make), 18also the standard C library. 19 20For deb based systems: 21 $ sudo apt-get install build-essential 22 On x86-64 systems you have to add the 32-bit compat headers: 23 $ sudo apt-get install libc6-dev-i386 24For Fedora based systems: 25 # yum install glibc-static 26For OpenSUSE based systems: 27 # zypper install glibc-devel-static 28 29Architectures which require device tree (PowerPC, ARM, ARM64, RISC-V) also 30require libfdt. 31 deb: $ sudo apt-get install libfdt-dev 32 Fedora: # yum install libfdt-devel 33 OpenSUSE: # zypper install libfdt1-devel 34Also see "Cross compiling" below. 35 36Optional libraries 37------------------- 38By running "make" some checks are invoked that determine the availability 39of certain optional libraries. Those are: 40- libbfd: enable symbol look-up support in debug mode 41- gtk3: enable support for displaying the guest framebuffer in a GTK+-3 window 42- vncserver: enable support for exporting the guest framebuffer in a VNC session 43- SDL: enable support for displaying the guest framebuffer in a SDL window 44- zlib: enable support for compressed QCOW images 45- aio: enable support for asynchronous I/O 46(Note that a guest framebuffer is currently only supported on x86.) 47So for the full glory you would need: 48(on a .deb based system): 49$ sudo apt-get install binutils-dev libgtk-3-dev libvncserver-dev libsdl2-dev \ 50 zlib1g-dev libaio-dev 51(on RPM based systems): 52# $TOOL install binutils-devel gtk3-devel libvncserver-devel SDL-devel \ 53 zlib-devel libaio-devel 54$TOOL is "yum" for Fedora and "zypper" for OpenSUSE. 55 56Cross compiling 57---------------- 58The Makefile will honour the CROSS_COMPILE environment variable when calling 59the compiler and the linker binary. To trigger cross compilation, also set ARCH 60to the Linux name of the architecture. Architectures supported: 61- i386 62- x86_64 63- powerpc 64- arm 65- arm64 66- mips 67- riscv 68If ARCH is not provided, the target architecture will be automatically 69determined by running "uname -m" on your host, resulting in a native build. 70 71To cross-compile to ARM for instance, install a cross-compiler, put the 72required libraries in the cross-compiler's SYSROOT and type: 73$ make CROSS_COMPILE=arm-linux-gnueabihf- ARCH=arm 74 75Missing libraries when cross-compiling 76--------------------------------------- 77The cross-compiler will look for target libraries in its SYSROOT directory, 78so you need to put the header and library files (.so) there. 79While most cross compiler packages come with the target's glibc already 80installed, optional libraries (or libfdt) maybe not. 81On multiarch system you should be able to install those be appending 82the architecture name after the package (example for ARM64): 83$ sudo apt-get install libfdt-dev:arm64 84 85PowerPC, ARM/ARM64 and RISC-V require libfdt to be installed. If you cannot use 86precompiled mulitarch packages, you could either copy the required header and 87library files from an installed target system into the SYSROOT (you will need 88/usr/include/*fdt*.h and /usr/lib64/libfdt-v.v.v.so and its symlinks), or you 89can cross-compile the libfdt library yourself: 90 91$ git clone git://git.kernel.org/pub/scm/utils/dtc/dtc.git 92$ cd dtc 93$ export CC=${CROSS_COMPILE}gcc 94$ make libfdt 95 96After compiling libfdt, the library can be installed system-wide: 97 98$ TRIPLET=$($CC -dumpmachine) 99$ SYSROOT=$($CC -print-sysroot) 100$ sudo make DESTDIR=$SYSROOT PREFIX=/usr LIBDIR=/usr/lib/$TRIPLET install-lib install-includes 101 102This assumes a multiarch-enabled system, if there is no per-arch directory for 103libraries, replace the LIBDIR paths above with LIBDIR=/usr/lib or /usr/lib64. 104 105Alternatively, if installing the shared library is not desirable or possible, 106you can instruct kvmtool to use the static library when compiling by using the 107variable LIBFDT_DIR. LIBFDT_DIR should point to the dtc/libfdt directory. 108kvmtool will include the static library LIBFDT_DIR/libfdt.a in the executable, 109removing the need for the shared library to be present on the system. 110LIBFDT_DIR, when set, takes precedence over the system library. 111