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

相关推荐
chian-ocean19 分钟前
Linux 文件缓冲区:高效数据访问的幕后推手
linux·运维·服务器
加油=^_^=20 分钟前
【Linux】进程优先级 | 进程调度(三)
linux·运维·服务器
吃汤圆的抹香鲸1 小时前
GoLand 安装包 绿色版 Win,Mac,Linux 包含IntelliJ全家桶 专为Go语言设计的集成开发环境(IDE)
linux·windows·macos·go·intellij-idea·go1.19
追寻光1 小时前
Cannot find a valid baseurl for repo: base/7/x86_64
linux
元气满满的热码式1 小时前
Docker数据卷操作实战
linux·运维·docker·云原生·容器
陆沙1 小时前
deepseek-r1-centos-本地服务器配置方法
linux·服务器·centos
吃汤圆的抹香鲸1 小时前
Rider 安装包 绿色版 Win/Mac/Linux 适合.NET和游戏开发者使用 2025全栈开发终极指南:从零配置到企业级实战
linux·运维·windows·sql·游戏·macos·.net
sz66cm2 小时前
Linux基础 -- ARM 32 位架构动态注入代码技术文档
linux·arm开发·架构
Mr.pyZhang4 小时前
Android构建系统 - 04 编译产物
android·linux
ansondroider8 小时前
Buildroot 添加自定义模块-内置文件到文件系统
linux·buildroot