安装基础工具
yum update
yum install wget sudo git libzstd vim openssl-devel bzip2-devel libffi-devel openssl readline-devel sqlite-devel ncurses-devel -y
yum groupinstall "Development Tools" -y
# ubuntu
# apt install libffi-dev pkg-config libglib2.0-dev
安装 Python3.9
wget https://www.python.org/ftp/python/3.9.19/Python-3.9.19.tar.xz
tar -xvf Python-3.9.19.tar.xz
cd Python-3.9.19
./configure
make -j80 # 80为CPU核心数 给成你的
make install
bash # 刷新缓存
安装 re2c
wget https://github.com/skvadrik/re2c/releases/download/3.1/re2c-3.1.tar.xz
tar -xvf re2c-3.1.tar.xz
cd re2c-3.1
./configure
make -j80
make install
export LD_LIBRARY_PATH=/usr/local/lib64:$LD_LIBRARY_PATH
安装较新的gcc
https://d5v.cc/?p=1711475037251
编译 Ninja
git clone https://github.com/ninja-build/ninja.git
克隆仓库速度慢的看这篇:
https://d5v.cc/?p=1711327005210
cd ninja
./configure.py --bootstrap # 编译
cp ninja /usr/bin/ # 复制二进制文件
cd .. && rm -rf ninja # 删除源代码
ninja --version # 检查是否成功
安装cmake
https://cmake.org/download/ 查看最先cmake 版本
wget https://github.com/Kitware/CMake/releases/download/v3.30.0-rc1/cmake-3.30.0-rc1-linux-x86_64.sh # 复制链接
chmod +x cmake-3.30.0-rc1-linux-x86_64.sh
./cmake-3.30.0-rc1-linux-x86_64.sh
rm cmake-3.30.0-rc1-linux-x86_64.sh # 删除安装包
mv cmake-3.30.0-rc1-linux-x86_64 /opt/cmake # 移动到/opt
echo "export PATH=\$PATH:/opt/cmake/bin/" >> /etc/profile # 添加环境变量
yum remove cmake # 删除yum安装的
source /etc/profile # 更新环境变量
cmake --version # 测试
编译 glib2
https://download.gnome.org/sources/glib/ 查看最新版 glib2
配置过程也会下载一些github仓库的文件 建议先配置代理 https://d5v.cc/?p=1711327005210
wget https://download.gnome.org/sources/glib/2.80/glib-2.80.0.tar.xz
tar -xvf glib-2.80.0.tar.xz
cd glib-2.80.0
pip3 install meson packaging ninja
meson _build
# 编译期间出错 使用 meson setup --reconfigure _build 清理缓存重新编译
ninja -C _build
cd _build
ninja install
编译 QEMU
yum insatll iasl tomli -y
git clone https://github.com/qemu/qemu.git # 克隆仓库
cd qemu
# 编译loong64
../configure --target-list=loongarch64-softmmu
make && make install
评论