qemu-8.1.0 源码编译安装
操作系统版本
CentOS Linux release 7.9.2009 (Core) 3.10.0-1160.el7.x86_64
依赖版本要求
Python >= 3.7
GCC >= v7.4
yum安装依赖
yum -y install bzip2 glib2 glib2-devel pixman pixman-devel flex bison
安装Python-3.9.0
yum -y install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gcc make libffi-devel
wget http://npm.taobao.org/mirrors/python/3.9.0/Python-3.9.0.tgz
tar -zxvf Python-3.9.0.tgz
cd Python-3.9.0
./configure --prefix=/usr/local/python3
make && make install
ln -s /usr/local/python39/bin/python3 /usr/bin/python3
ln -s /usr/local/python39/bin/pip3 /usr/bin/pip3
rm -rf /usr/bin/python
ln -s /usr/local/python39/bin/python3 /usr/bin/python
rm -rf /usr/bin/pip
ln -s /usr/local/python39/bin/pip3 /usr/bin/pip
yum必须使用python2,需要修改yum配置
vim /usr/bin/yum
把 #! /usr/bin/python 修改为 #! /usr/bin/python2
vim /usr/libexec/urlgrabber-ext-down
把 #! /usr/bin/python 修改为 #! /usr/bin/python2
vim /usr/bin/yum-config-manager
#!/usr/bin/python 改为 #!/usr/bin/python2
安装Ninja
yum -y install re2c git
git clone git://github.com/ninja-build/ninja.git && cd ninja
./configure.py --bootstrap
cp ninja /usr/bin/
ninja --version
升级gcc版本
cat > /etc/yum.repos.d/CentOS-SCLo-scl.repo <<'EOF'
[centos-sclo-sclo]
name=CentOS-7 - SCLo sclo
baseurl=http://mirror.centos.org/centos/7/sclo/$basearch/rh/
#mirrorlist=http://mirrorlist.centos.org?arch=$basearch&release=7&repo=sclo-sclo
gpgcheck=0
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-SIG-SCLo
yum -y install devtoolset-11-gcc*
每个版本下面都会有个enable文件,执行以下命令即可启用
cd /opt/rh/devtoolset-11/
scl enable devtoolset-11 bash
source ./enable
永久生效
mv /usr/bin/gcc /usr/bin/gcc-4.8.5
ln -s /opt/rh/devtoolset-11/root/bin/gcc /usr/bin/gcc
mv /usr/bin/g++ /usr/bin/g++-4.8.5
ln -s /opt/rh/devtoolset-11/root/bin/g++ /usr/bin/g++
查看版本是正确
gcc --version
g++ --version
安装qemu
qemu下载地址
https://www.qemu.org/download/#source
tar xvJf qemu-8.1.0.tar.xz
cd qemu-8.1.0
./configure
make
执行make后,时间比较
相关错误提示
Using './build' as the directory for build output
WARNING: unrecognized host CPU, proceeding with 'uname -m' output 'x86_64'
ERROR: Cannot use '/usr/bin/python', Python >= 3.7 is required.
Use --python=/path/to/python to specify a supported Python.
Maybe try:
openSUSE Leap 15.3+: zypper install python39
CentOS 8: dnf install python38
ERROR: Cannot find Ninja
ERROR: Program 'bzip2' not found or not executable
ERROR: Problem encountered: You either need GCC v7.4 or Clang v10.0 (or XCode Clang v12.0) to compile QEMU
ERROR: Dependency "glib-2.0" not found, tried pkgconfig
ERROR: Dependency "pixman-1" not found, tried pkgconfig
ERROR: Program 'flex' not found or not executable