qemu-8.1.0 源码编译安装

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

相关推荐
五味香13 分钟前
Linux学习,ip 命令
linux·服务器·c语言·开发语言·git·学习·tcp/ip
朱容君2 小时前
Linux系统编程多线程之读写锁讲解
linux·开发语言
大风吹PP凉2 小时前
38配置管理工具(如Ansible、Puppet、Chef)
linux·运维·服务器·ansible·puppet
康熙38bdc2 小时前
Linux 进程间通信——共享内存
linux·运维·服务器
jwybobo20072 小时前
redis7.x源码分析:(3) dict字典
linux·redis
scoone2 小时前
ssh登陆服务器后支持Tab键命令补全
linux·shell
运维佬3 小时前
CentOS 9 配置网卡
linux·centos
轩轩曲觞阁4 小时前
Linux网络——网络初识
linux·网络
2401_840192274 小时前
python基础大杂烩
linux·开发语言·python
weixin_438197384 小时前
K8S创建云主机配置docker仓库
linux·云原生·容器·eureka·kubernetes