CentOS7.6Arm Qt开发环境(GCC+Qt5+QtCreator+JDK8+MySQL8+CMake+ProtoBuf+Python+SVN)

4 篇文章 0 订阅

1 QEMU安装

Windows系统安装QEMU:qemu-w64-setup-20210415.exe。完成后安装虚拟网卡:tap-windows-9.21.2.exe。完成后,配置虚拟网卡与本地网络的网桥,实现虚拟机对公网的访问。详情暂略。
在这里插入图片描述

2 虚拟机创建

Note: windows中均以管理员身份运行命令提示符,进入qemu安装目录下执行qemu命令。

2.1 下载

CentOS-7-aarch64-Everything-1810.iso,下载地址:https://archive.kernel.org/centos-vault/altarch/7.6.1810/isos/aarch64/。

2.2 创建虚拟磁盘

命令提示符中,执行命令:

# qemu-img.exe create -f qcow2 D:\g5\kunpeng.qcow2 100g

在这里插入图片描述

2.3 启动虚拟机安装

命令提示符中,执行命令:

\# qemu-system-aarch64.exe -M virt -cpu cortex-a72 -bios D:\qemu\share\edk2-aarch64-code.fd -m 8192 -net nic -net tap,ifname=tap0 -device nec-usb-xhci -device usb-kbd -device usb-mouse -device VGA -drive file=D:\shao\CentOS-7-aarch64-Everything-1810.iso,if=none,id=cdrom,media=cdrom -device virtio-scsi-device -device scsi-cd,drive=cdrom -drive file=d:\g5\kunpeng.qcow2,if=none,id=hd0 -device virtio-blk-device,drive=hd0

在出现的QEMU工具中,视图–>serial0,即可在QEMU的操作系统安装界面使用键盘。
出现该界面时,切换视图–>VGA,进入CentOS安装界面。

在这里插入图片描述

选择中文,软件选择的基本环境为“GNOME桌面”(附加选项一概不勾)。注意:QEMU全屏,避免鼠标漂移。
在重启后,配置网络,手动配置为与宿主机网段一致(宿主机与网桥网段一致)。

2.4 启动虚拟机系统

命令提示符中,执行命令

方法一–利用tap网桥:

# qemu-system-aarch64.exe -m 10240 -cpu cortex-a72 -smp 8,cores=8,threads=1,sockets=1 -M virt -bios D:\qemu\share\edk2-aarch64-code.fd -net nic -net tap,ifname=tap0 -device nec-usb-xhci -device usb-kbd -device usb-mouse -device VGA -drive file=d:\g5\kunpeng.qcow2,if=none,id=hd0 -device virtio-blk-device,drive=hd0

方法二–无需tap网桥(利用本地连接):

# qemu-system-aarch64.exe -m 10240 -cpu cortex-a72 -smp 8,cores=8,threads=1,sockets=1 -M virt -bios D:\qemu\share\edk2-aarch64-code.fd -netdev user,id=n0 -device rtl8139,netdev=n0 -device nec-usb-xhci -device usb-kbd -device usb-mouse -device VGA -drive file=d:\g5\kunpeng.qcow2,if=none,id=hd0 -device virtio-blk-device,drive=hd0

3 GCC、JDK环境

Note:以下各章节的yum使用,如需准备离线环境下的yum仓库目录。对于联网Linux主机有2种方法:

  1. 先免安装下载,再安装下载,否则yum本地仓库目录下将无rpm包下载,且切记每次分别用不同的目录,否则上一个本地仓库目录内容会被清理,切记切记。例如:

     # yum install --downloadonly --downloaddir=/home/g5/ThirdPart/YumLocalRepo/ mesa-libGL-devel
     # yum -y install --downloaddir=/home/g5/ThirdPart/YumLocalRepo/ mesa-libGL-devel
    
  2. yum安装后保留rpm安装包

    可以设置升级后不删除下载的rpm包

    vi /etc/yum.conf
    [main]
    cachedir=/var/cache/yum
    keepcache=0
    

    将 keepcache=0 修改为 keepcache=1, 安装或者升级后,在目录 /var/cache/yum下就会有下载的 rpm 包。

以下安装GCC、编译Qt的方法除参考Qt源码中的README外,参考鲲鹏云论坛的几篇文章:

  • Qt 5.13.0编译移植指导 for centos 7.6 ★★★_迁移调优实践_鲲鹏论坛_华为云论坛 (huaweicloud.com)
  • Qt-5.13 编译移植指导 for 鲲鹏CentOS-7.6 补充QtWebEngine_鲲鹏论坛_华为云论坛 (huaweicloud.com)

在此致谢!

3.1 GCC

3.1.1 方法一

注意:此路不通!
鉴于华为官方推荐,采用鲲鹏GCC。下载gcc-9.3.1-2021.03-aarch64-linux.tar.gz(绿色版,下载地址:https://mirrors.huaweicloud.com/kunpeng/archive/compiler/kunpeng_gcc/)。/data/soft目录下解压(该绿色版gcc在编译时指定的安装目录)。

#tar -zxvf gcc-9.3.1-2021.03-aarch64-linux.tar.gz
#mv gcc-9.3.1-2021.03-aarch64-linux/ gcc
#vim /etc/profile

末尾换行添加环境变量:

export PATH=/data/soft/gcc-9.3.1-2021.03-aarch64-linux/bin:$PATH
export INCLUDE=/data/soft/gcc-9.3.1-2021.03-aarch64-linux/include:$INCLUDE
export LD_LIBRARY_PATH=/data/soft/gcc-9.3.1-2021.03-aarch64-linux/lib64:$LD_LIBRARY_PATH

保存后,强制生效:

#source /etc/profile

最简单的helloword没法编译通过(报找不到stdio.h文件错误)!
以上GCC安装方法出自《鲲鹏架构入门与实战》10.2鲲鹏GCC,经以上实践证明有误。
鲲鹏GCC环境构建比较靠谱的方式时编译–安装,参考:鲲鹏服务器实验一:GCC编译安装_鲲鹏论坛_华为云论坛 (huaweicloud.com)。但是目前考虑太慢,没有使用鲲鹏GCC,而是Yum SCL源安装devtoolset方式,见下节。

Note:如果计划采用交叉编译开发,可以参考【鲲鹏翱翔】鲲鹏服务器GCC交叉编译环境搭建指南_迁移调优实践_鲲鹏论坛_华为云论坛 (huaweicloud.com)。

3.1.2 方法二

注意:此方法对于x86 CentOS7.6或Arm CentOS7.6的非Qt开发环境没有问题,对于Arm CentOS7.6的Qt5环境则无法支持。
利用Yum SCL源安装devtoolset-9的方式。
安装Yum SCL源:

#yum -y install centos-release-scl

由于gcc包含在Development Tools组中,scl中的gcc/g++软件包的前缀都是devtoolset,目前已经存在版本10,这里安装devtoolset-9。

# yum list devtoolset-9
# yum -y install devtoolset-9

所安装/更新内容如下:

依赖关系解决

Package 架构 版本 源 大小

==========================================================
正在安装:
devtoolset-9 aarch64 9.1-0.el7 centos-sclo-rh 5.4 k
为依赖而安装:
boost-regex aarch64 1.53.0-28.el7 base 267 k
cpp aarch64 4.8.5-44.el7 base 5.2 M
ctags aarch64 5.8-13.el7 base 149 k
devtoolset-9-binutils aarch64 2.32-16.el7 centos-sclo-rh 6.2 M
devtoolset-9-dwz aarch64 0.12-1.1.el7 centos-sclo-rh 94 k
devtoolset-9-elfutils aarch64 0.176-6.el7 centos-sclo-rh 429 k
devtoolset-9-elfutils-libelf aarch64 0.176-6.el7 centos-sclo-rh 201 k
devtoolset-9-elfutils-libs aarch64 0.176-6.el7 centos-sclo-rh 299 k
devtoolset-9-gcc aarch64 9.3.1-2.2.el7 centos-sclo-rh 26 M
devtoolset-9-gcc-c++ aarch64 9.3.1-2.2.el7 centos-sclo-rh 10 M
devtoolset-9-gcc-gfortran aarch64 9.3.1-2.2.el7 centos-sclo-rh 10 M
devtoolset-9-gdb aarch64 8.3-3.el7 centos-sclo-rh 3.2 M
devtoolset-9-libstdc+±devel aarch64 9.3.1-2.2.el7 centos-sclo-rh 3.1 M
devtoolset-9-ltrace aarch64 0.7.91-2.el7 centos-sclo-rh 141 k
devtoolset-9-make aarch64 1:4.2.1-2.el7 centos-sclo-rh 480 k
devtoolset-9-memstomp aarch64 0.1.5-5.el7 centos-sclo-rh 369 k
devtoolset-9-oprofile aarch64 1.3.0-4.el7 centos-sclo-rh 1.7 M
devtoolset-9-perftools aarch64 9.1-0.el7 centos-sclo-rh 2.8 k
devtoolset-9-runtime aarch64 9.1-0.el7 centos-sclo-rh 20 k
devtoolset-9-strace aarch64 5.1-7.el7 centos-sclo-rh 1.0 M
devtoolset-9-systemtap aarch64 4.1-9.el7 centos-sclo-rh 13 k
devtoolset-9-systemtap-client aarch64 4.1-9.el7 centos-sclo-rh 2.8 M
devtoolset-9-systemtap-devel aarch64 4.1-9.el7 centos-sclo-rh 2.1 M
devtoolset-9-systemtap-runtime aarch64 4.1-9.el7 centos-sclo-rh 375 k
devtoolset-9-toolchain aarch64 9.1-0.el7 centos-sclo-rh 3.0 k
devtoolset-9-valgrind aarch64 1:3.15.0-9.el7 centos-sclo-rh 9.3 M
gcc aarch64 4.8.5-44.el7 base 13 M
glibc-devel aarch64 2.17-325.el7_9 updates 1.1 M
glibc-headers aarch64 2.17-325.el7_9 updates 673 k
kernel-debug-devel aarch64 4.18.0-305.10.2.el7 updates 18 M
kernel-headers aarch64 4.18.0-305.10.2.el7 updates 7.1 M
libgfortran5 aarch64 8.3.1-2.1.1.el7 base 497 k
source-highlight aarch64 3.1.6-6.el7 base 592 k
为依赖而更新:
glibc aarch64 2.17-325.el7_9 updates 3.6 M
glibc-common aarch64 2.17-325.el7_9 updates 12 M
libgcc aarch64 4.8.5-44.el7 base 97 k
libgomp aarch64 4.8.5-44.el7 base 155 k

使能RHSCL仓库

#yum-config-manager --enable rhel-server-rhscl-9-rpms

Gcc使能:
(1) SCL命令方式临时启用安装的gcc(退出shell或重启后会恢复原系统gcc版本)

#scl enable devtoolset-9 bash

(2) 写入环境变量长期生效

#echo "source /opt/rh/devtoolset-9/enable" >> /etc/profile
#source /etc/profile

在这里插入图片描述

且helloword编译通过!

3.1.3 方法三(实用的方法)

编译GCC7.2源码。

3.1.3.1 YUM源准备

添加SCL、epol等YUM源,鲲鹏云的源暂未加入。

# yum -y install centos-release-scl
# yum -y install epel-release
3.1.3.2 安装基础依赖

此处不仅有GCC的依赖,还有大量的Qt依赖。

# yum	  install gcc gcc-c++
# yum   install mesa* libglvnd-opengl freeglut libGLEW
# yum   install xcb* libxcb*
# yum   install libX11-devel libXext-devel libXtst-devel libxkbcommon-devel   libXrender libXrender-devel libgcrypt-devel libgcrypt pciutils-devel   nss-devel cups-devel pulseaudio-libs-devel libgudev1-devel systemd-devel   libcap-devel alsa-lib-devel ruby dbus libXrandr-devel libXcomposite-devel   libXcursor-devel dbus-devel fontconfig-devel
3.1.3.3 升级GCC

查看GCC版本,若是7.2以下的版本,则升级至7.2.0版本

# gcc   -v

升级操作如下:

gcc 7.2.0编译依赖gmp、mpfr、mpc 3个库,mpfr依赖gmp,而mpc依赖gmp和mpfr,因此安装gcc-7.2.0之前首先根据依赖关系依次安装3个库(软件版本:gmp-6.1.2,mpfr-3.1.5,mpc-1.0.3,gcc-7.2.0)

  1. 编译安装gmp

    gmp对m4有依赖,需要先装上。

     yum	 -y  install m4
     wget   https://ftp.gnu.org/gnu/gmp/gmp-6.1.2.tar.bz2 --no-check-certificate
     tar   -xvf gmp-6.1.2.tar.bz2
     cd   gmp-6.1.2
     ./configure   --prefix=/usr/local/gmp-6.1.2
     make
     make   install
    
  2. 编译安装mpfr

     wget   https://ftp.gnu.org/gnu/mpfr/mpfr-3.1.5.tar.gz --no-check-certificate
     tar   -zxvf mpfr-3.1.5.tar.gz
     cd   mpfr-3.1.5
     ./configure   --prefix=/usr/local/mpfr-3.1.5 --with-gmp=/usr/local/gmp-6.1.2
     make
     make   install
    
  3. 编译安装mpc

     wget   https://ftp.gnu.org/gnu/mpc/mpc-1.0.3.tar.gz --no-check-certificate
     tar   -zxvf mpc-1.0.3.tar.gz
     cd   mpc-1.0.3
     ./configure   -prefix=/usr/local/mpc-1.0.3 -with-gmp=/usr/local/gmp-6.1.2   -with-mpfr=/usr/local/mpfr-3.1.5
     make
     make   install
    
  4. 编译安装gcc 7.2.0

     wget   https://ftp.gnu.org/gnu/gcc/gcc-7.2.0/gcc-7.2.0.tar.gz --no-check-certificate
     tar   -zxvf gcc-7.2.0.tar.gz
     cd   gcc-7.2.0
     ./configure   --prefix=/usr/local/gcc-7.2.0 --enable-languages=c,c++,fortran   --enable-shared --enable-linker-build-id --without-included-gettext   --enable-threads=posix --disable-multilib --disable-nls   --disable-libsanitizer --disable-browser-plugin --enable-checking=release   --build=aarch64-linux  --with-gmp=/usr/local/gmp-6.1.2   --with-mpfr=/usr/local/mpfr-3.1.5 --with-mpc=/usr/local/mpc-1.0.3
     export   LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/mpc-1.0.3/lib:/usr/local/gmp-6.1.2/lib:/usr/local/mpfr-3.1.5/lib
     nohup make   -j 8 >> GCCBuild.log &
     nohup make   -j 8 install  >> GCCInstall.log &
    

安装完成后在/etc/profile文件添加如下环境变量:

	export   LD_LIBRARY_PATH=/usr/local/mpc-1.0.3/lib:/usr/local/gmp-6.1.2/lib:/usr/local/mpfr-3.1.5/lib:/usr/local/gcc-7.2.0/lib64:/usr/local/lib:/usr/lib:$LD_LIBRARY_PATH
	export   PATH=/usr/local/gcc-7.2.0/bin:$PATH

保存退出,并使环境变量生效:

	source   /etc/profile

检查gcc版本,变为7.2.0

	#  gcc -v

3.2 JDK

3.2.1 方法一

《鲲鹏架构入门与实战》10.3毕昇JDK推荐,采用毕昇JDK,bisheng-jdk-8u302-linux-aarch64.tar.gz。下载地址:鲲鹏编译器-鲲鹏社区 (hikunpeng.com)、Index of /kunpeng/archive/compiler/bisheng_jdk/ (iscas.ac.cn)、毕昇JDK 8 安装指南 - Wiki - Gitee.com。

3.2.2 方法二

由于系统带有OpenJDK(其中仅存在JRE,除不具备开发环境外,运行时环境具备,故暂不安装其它JDK)。

在这里插入图片描述

3.2.3 方法三

RPM方式安装Oracle JDK,RPM:jdk-8u291-linux-aarch64.rpm,下载地址:https://www.oracle.com/java/technologies/downloads/#java8。

# rpm -ivh jdk-8u291-linux-aarch64.rpm

一般无需事后额外配置环境变量,rpm安装过程中会自动配置。

4 MySQL环境

4.1 下载

mysql-8.0.25-1.el7.aarch64.rpm-bundle.tar。地址:MySQL :: Download MySQL Community Server (Archived Versions)。注意:之所以用mysql8,是因为对于Arm Linux,MySQL官网不提供mysql5.7的安装包。

4.2 安装

注意:MySQL8的环境安装配置建议参考另一篇博客《Arm CentOS7.6的MySQL8数据库安装配置》,本节内容仅供参考。

4.2.1 关闭SELINUX

vim /etc/selinux/config

把SELINUX=enforcing改为SELINUX=disabled
重启,避免SELINUX干扰MySQL启动。

4.2.2 查询并卸载MariaDB

# rpm -qa | grep mariadb
mariadb-libs-5.5.60-1.el7_5.aarch64
# rpm -e --nodeps mariadb-libs-5.5.60-1.el7_5.aarch64

4.2.3 安装MySQL

安装依赖的openssl

# yum -y install openssl openssl-devel
软件包 1:openssl-1.0.2k-22.el7_9.aarch64 已安装并且是最新版本
软件包 1:openssl-devel-1.0.2k-22.el7_9.aarch64 已安装并且是最新版本
无须任何处理

解压:

# tar -xvf mysql-8.0.25-1.el7.aarch64.rpm-bundle.tar

逐个安装:

# rpm -ivh mysql-community-common-8.0.25-1.el7.aarch64.rpm
# rpm -ivh mysql-community-client-plugins-8.0.25-1.el7.aarch64.rpm
# rpm -ivh mysql-community-libs-8.0.25-1.el7.aarch64.rpm
# rpm -ivh mysql-community-libs-compat-8.0.25-1.el7.aarch64.rpm
# rpm -ivh mysql-community-client-8.0.25-1.el7.aarch64.rpm
# rpm -ivh mysql-community-server-8.0.25-1.el7.aarch64.rpm
# rpm -ivh mysql-community-devel-8.0.25-1.el7.aarch64.rpm
# rpm -ivh mysql-community-embedded-compat-8.0.25-1.el7.aarch64.rpm

注意:如果是解压版安装需要执行以下2条命令,分别初始化mysql配置且随机生成root账户的密码、配置MySQL安装目录的用户为MySQL:

# mysqld --initialize
# chown mysql:mysql -R /var/lib/mysql

4.2.4 设置

找出初始密码(稍微多等一会儿再操作,MySQL服务初始化需要时间):

# grep "password" /var/log/mysqld.log 
2021-10-20T11:06:52.967906Z 6 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: 8jbk/qTprPgl

启动mysql服务

# systemctl start mysqld.service

查看mysql服务状态

# systemctl status mysqld.service

进入数据库

# mysql -uroot -p

MySQL默认必须修改密码后才能操作数据库,修改密码前需要更改密码有效性策略validate_password_policy,再修改密码(注意:arm Linux MySQL的是validate_password.policy,x86 Linux MySQL的是validate_password_policy,以下命令需一气呵成执行)

mysql>   set global validate_password.policy=LOW;
mysql>   set global validate_password.length=1;
mysql>   set global validate_password.check_user_name=OFF;
mysql>   ALTER USER 'root'@'localhost' IDENTIFIED BY '123456';

4.2.5 远程登录设置

4.2.5.1 授权任意IP以root用户登录

原有MySQL5.7的方式(MySQL8不准许用):

mysql>  grant all privileges on *.* to 'root'@'%' identified by '123456' with grant option; 

MySQL8目前暂时采用暴力方式改user表(8.0之后的加密规则发生了改变,navicat的默认规则与之不符,所以,需要把服务器上的MySQL的加密规则改为之前的加密规则mysql_native_password):

mysql> use mysql;
mysql> select user, host from user;
mysql> update user set host="%" where user="root";
mysql> alter user 'root'@'%' identified with mysql_native_password by '123456' password expire never;

重载授权表

mysql> flush privileges;
4.2.5.2 开放3306端口
# firewall-cmd --zone=public --add-port=3306/tcp --permanent
# firewall-cmd --reload
# firewall-cmd --list-ports
4.2.5.3 服务开机自启动
# systemctl enable mysqld

5 Qt开发环境

5.1 Qt下载

qt-everywhere-src-5.13.1.tar.xz,下载地址:

http://mirrors.ustc.edu.cn/qtproject/archive/qt/5.13/5.13.1/single/qt-everywhere-src-5.13.1.tar.xz.即:https://download.qt.io/archive/qt/5.13/5.13.1/single/qt-everywhere-src-5.13.1.tar.xz.

qt-creator-opensource-src-4.10.0.tar.gz,下载地址:

http://mirrors.ustc.edu.cn/qtproject/official_releases/qtcreator/4.10/4.10.0/qt-creator-opensource-src-4.10.0.tar.gz.即:Index of /official_releases/qtcreator/4.10/4.10.0/qt-creator-opensource-src-4.10.0.tar.gz.

5.2 编译安装

5.2.1 注意事项

  1. configure中,-qt-xcb应该是需要(其相关rpm包前面已经安装,多处资料声称需要该选项);
  2. configure中,由于需要编译mysql连接驱动,所以需要-sql-mysql;
  3. Qt5.13.0版本中对于aarch64架构,其部分源码(QWebEngine)的处理存在Bug,更改源码据说能掩盖部分问题,比较直接的方法是不用QWebEngine,则选择不安装flex、bison、gperf,这3个RPM包为QWebEngine所依赖,一旦安装,QWebEngine就会安装,目前只能选择不安装(不执行:yum install flex bison gperf);
  4. -prefix不写:不指定安装命令,默认在/usr/local/下新建Qt目录安装,-nomake tests指定禁用tests构建以加速编译,-opensource指定为开源版而非商业版,-confirm-license指定默认同意LGPL2.1 license,make -j 8指定8核编译;
  5. configure中LLVM/Clang找不到的问题一直存在警告,暂不管;
  6. configure如果中间出错了,需要清除缓存之后再重新执行:rm -rf config.cache;
  7. configure中,-debug、-release互斥,如果同时存在,最后一个生效,所以目前不加任何一个(默认release);
  8. 编译实际较长,需要挂起(nohup)且后台执行(&),避免连接断开后进程推出;
  9. 编译结果重定向到日志文件,便于查看(目前32000余行);
  10. 编译时间,对于QEMU虚拟机8核/线程,8小时,对于华为云物理机2核/线程,近3小时完成。

5.2.2 安装Perl

README要求Perl 5.8 or later。经查询已安装5.16,跳过本步骤。

在这里插入图片描述

5.2.3 安装Python

README要求Python 2.7 or later。经查询已安装2.7.5,跳过本步骤。

在这里插入图片描述

5.2.4 安装C++编译器

README要求C++ compiler supporting the C++11 standard。由于已经安装GCC7,则跳过本步骤。

5.2.5 编译

# tar -xvf qt-everywhere-src-5.13.1.tar.xz
# cd ./qt-everywhere-src-5.13.1
# ./configure -prefix /opt/Qt5.13.1 -opensource --confirm-license -nomake tests -sql-mysql -qt-zlib -qt-libpng -qt-libjpeg -openssl -opengl -qt-xcb
# nohup gmake -j 8 >> QtBuild.log &
# gmake install

vim /etc/profile,末尾添加

export QTDIR=/opt/Qt5.13.1
export PATH=$QTDIR/bin:$PATH
export MANPATH=$QTDIR/man:$MANPATH
export LD_LIBRARY_PATH=$QTDIR/lib:$LD_LIBRARY_PATH

# source /etc/profile

5.2.6 测试

5.2.6.1 编译并生成helloworld
  1. 创建helloworld目录,在目录下vi helloworld.cpp,写入如下代码

    #include<QApplication>
    #include<QLabel>
    int main(int argc,char *argv[])
    {
    QApplication app(argc,argv);
    QLabel *label=new QLabel("helloworld!");
    label->show();
    return app.exec();
    }
    
  2. 编译

     qmake -project
     qmake
     make
    
  3. 执行make如报以下错误,则修改helloworld.pro文件,在文件末尾加 QT += widgets

在这里插入图片描述

  1. 执行./helloworld ,会弹出对话框

在这里插入图片描述

5.2.6.2 编译并生成standarddialogs项目
  1. 使用示例源码:

     cd   /usr/local/Qt-5.13.0/examples/widgets/dialogs/standarddialogs
    
  2. 编译执行过程及效果

     qmake   standarddialogs.pro
     make   -j 64
     ./standarddialogs
    

在这里插入图片描述

注意:在使用XShell执行时,Linux的X Window System的图形界面是转发到XShell显示,拖拽、缩放引起的崩溃并非是Qt的问题。

5.2.7 编译Qt Creator

# cd ./qt-creator-opensource-src-4.10.0
# qmake -r
# nohup make -j 8 >> QtCreatorMake.log

虚拟机可以拍个快照再继续(避免丢失成果)

# make install INSTALL_ROOT=/opt/QtCreator

5.2.8 环境配置

5.2.8.1 遗留Qt5卸载

遗留Qt5查询:

[root@localhost QtCreator]# rpm -qa | grep qt
qt5-qtbase-common-5.9.2-3.el7.noarch
adwaita-qt5-1.0-1.el7.aarch64
qt5-qtbase-5.9.2-3.el7.aarch64
highcontrast-qt5-0.1-2.el7.aarch64
qt5-qtbase-gui-5.9.2-3.el7.aarch64

卸载尝试:

[root@localhost QtCreator]# rpm -e qt5-qtbase-gui-5.9.2-3.el7.aarch64
错误:依赖检测失败:
	libQt5Gui.so.5()(64bit) 被 (已安裝) qt5-qtbase-5.9.2-3.el7.aarch64 需要
	libQt5Gui.so.5()(64bit) 被 (已安裝) adwaita-qt5-1.0-1.el7.aarch64 需要
	libQt5Gui.so.5()(64bit) 被 (已安裝) highcontrast-qt5-0.1-2.el7.aarch64 需要
	libQt5Gui.so.5()(64bit) 被 (已安裝) qgnomeplatform-0.3-3.el7.aarch64 需要
	libQt5Gui.so.5(Qt_5)(64bit) 被 (已安裝) qt5-qtbase-5.9.2-3.el7.aarch64 需要
	libQt5Gui.so.5(Qt_5)(64bit) 被 (已安裝) adwaita-qt5-1.0-1.el7.aarch64 需要
	libQt5Gui.so.5(Qt_5)(64bit) 被 (已安裝) highcontrast-qt5-0.1-2.el7.aarch64 需要
	libQt5Gui.so.5(Qt_5)(64bit) 被 (已安裝) qgnomeplatform-0.3-3.el7.aarch64 需要
	libQt5Gui.so.5(Qt_5_PRIVATE_API)(64bit) 被 (已安裝) qt5-qtbase-5.9.2-3.el7.aarch64 需要
	libQt5Gui.so.5(Qt_5_PRIVATE_API)(64bit) 被 (已安裝) qgnomeplatform-0.3-3.el7.aarch64 需要
	libQt5Widgets.so.5()(64bit) 被 (已安裝) adwaita-qt5-1.0-1.el7.aarch64 需要
	libQt5Widgets.so.5()(64bit) 被 (已安裝) highcontrast-qt5-0.1-2.el7.aarch64 需要
	libQt5Widgets.so.5()(64bit) 被 (已安裝) qgnomeplatform-0.3-3.el7.aarch64 需要
	libQt5Widgets.so.5(Qt_5)(64bit) 被 (已安裝) adwaita-qt5-1.0-1.el7.aarch64 需要
	libQt5Widgets.so.5(Qt_5)(64bit) 被 (已安裝) highcontrast-qt5-0.1-2.el7.aarch64 需要
	libQt5Widgets.so.5(Qt_5)(64bit) 被 (已安裝) qgnomeplatform-0.3-3.el7.aarch64 需要

[root@localhost QtCreator]# rpm -e qt5-qtbase-5.9.2-3.el7.aarch64
错误:依赖检测失败:
	libQt5Core.so.5()(64bit) 被 (已安裝) qt5-qtbase-gui-5.9.2-3.el7.aarch64 需要
	libQt5Core.so.5()(64bit) 被 (已安裝) adwaita-qt5-1.0-1.el7.aarch64 需要
	libQt5Core.so.5()(64bit) 被 (已安裝) highcontrast-qt5-0.1-2.el7.aarch64 需要
	libQt5Core.so.5()(64bit) 被 (已安裝) qgnomeplatform-0.3-3.el7.aarch64 需要
	libQt5Core.so.5(Qt_5)(64bit) 被 (已安裝) qt5-qtbase-gui-5.9.2-3.el7.aarch64 需要
	libQt5Core.so.5(Qt_5)(64bit) 被 (已安裝) adwaita-qt5-1.0-1.el7.aarch64 需要
	libQt5Core.so.5(Qt_5)(64bit) 被 (已安裝) highcontrast-qt5-0.1-2.el7.aarch64 需要
	libQt5Core.so.5(Qt_5)(64bit) 被 (已安裝) qgnomeplatform-0.3-3.el7.aarch64 需要
	libQt5Core.so.5(Qt_5_PRIVATE_API)(64bit) 被 (已安裝) qt5-qtbase-gui-5.9.2-3.el7.aarch64 需要
	libQt5DBus.so.5()(64bit) 被 (已安裝) qt5-qtbase-gui-5.9.2-3.el7.aarch64 需要
	libQt5DBus.so.5()(64bit) 被 (已安裝) adwaita-qt5-1.0-1.el7.aarch64 需要
	libQt5DBus.so.5()(64bit) 被 (已安裝) highcontrast-qt5-0.1-2.el7.aarch64 需要
	libQt5DBus.so.5()(64bit) 被 (已安裝) qgnomeplatform-0.3-3.el7.aarch64 需要
	libQt5DBus.so.5(Qt_5)(64bit) 被 (已安裝) qt5-qtbase-gui-5.9.2-3.el7.aarch64 需要
	libQt5DBus.so.5(Qt_5)(64bit) 被 (已安裝) adwaita-qt5-1.0-1.el7.aarch64 需要
	libQt5DBus.so.5(Qt_5)(64bit) 被 (已安裝) highcontrast-qt5-0.1-2.el7.aarch64 需要
	libQt5EglFSDeviceIntegration.so.5()(64bit) 被 (已安裝) qt5-qtbase-gui-5.9.2-3.el7.aarch64 需要
	libQt5Network.so.5()(64bit) 被 (已安裝) qt5-qtbase-gui-5.9.2-3.el7.aarch64 需要
	libQt5Network.so.5(Qt_5)(64bit) 被 (已安裝) qt5-qtbase-gui-5.9.2-3.el7.aarch64 需要
	qt5-qtbase = 5.9.2-3.el7 被 (已安裝) qt5-qtbase-common-5.9.2-3.el7.noarch 需要
	qt5-qtbase 被 (已安裝) highcontrast-qt5-0.1-2.el7.aarch64 需要
	qt5-qtbase(aarch-64) = 5.9.2-3.el7 被 (已安裝) qt5-qtbase-gui-5.9.2-3.el7.aarch64 需要
	qt5-qtbase(aarch-64) = 5.9.2 被 (已安裝) qgnomeplatform-0.3-3.el7.aarch64 需要

[root@localhost QtCreator]# rpm -e qt5-qtbase-common-5.9.2-3.el7.noarch
错误:依赖检测失败:
	qt5-qtbase-common = 5.9.2-3.el7 被 (已安裝) qt5-qtbase-5.9.2-3.el7.aarch64 需要

系统依赖过多,暂不处理。

5.2.8.2 环境变量

/etc/profile末尾添加环境变量

export PATH=/opt/QtCreator/bin:$PATH
export LD_LIBRARY_PATH=/opt/QtCreator/lib:$LD_LIBRARY_PATH
export QT_PLUGIN_PATH=$QTDIR/plugins:$QT_PLUGIN_PATH
export QML2_IMPORT_PATH=$QTDIR/qml:$QML2_IMPORT_PATH

# source /etc/profile

PS:

  1. 64位的linux机器上的默共享库的查找路径为:/lib64 /usr/lib64。实测发现不会搜索/lib /usr/lib。而且以上的两个目录没有什么so文件。/usr/local/lib64、/usr/local/lib 这两个目录也不会搜索的。

  2. 动态库的搜索路径搜索的先后顺序是: //注释:居然没有当前路径**

    1.编译目标代码时指定的动态库搜索路径; //LDIRNAME   
    2.环境变量LD_LIBRARY_PATH指定的动态库搜索路径;   
    3.配置文件/etc/ld.so.conf中指定的动态库搜索路径;//只需在在该文件中追加一行库所在的完整路径如"/root/test/conf/lib"即可,然后ldconfig是修改生效。(实际上是根据缓存文件/etc/ld.so.cache来确定路径)   
    4.默认的动态库搜索路径/lib;(64位机器为/lib64)   
    5.默认的动态库搜索路径/usr/lib。(64位机器为/usr/lib64)
    
  3. 关于ldconfig

    a) ldconfig主要的作用是根据/etc/ld.so.conf 的内容,查找内容中所包含目录下实际的动态库文件,生成搜索共享库的缓存文件/etc/ld.so.cache 。
    b) 缓存必须与实际路径的文件相一致。机器比较傻,只认缓存,然后按照缓存的路径去实际路径查找文件。增加或删除了实际的共享库路径下的文件,而没有更新缓存,执行被其依赖的可执行文件时会出错。 
    c) 查看共享库的缓存内容。ldconfig -p。
    
  4. /lib 或 /usr/lib(64位系统下为/lib64 /usr/lib64)路径下的共享库比较特殊。

    a) 它是默认的共享库的搜索路径。
    b) 它没有放到/etc/ld.so.conf 文件中。但是在/etc/ld.so.cache 的缓存中有它。 
    c) 其路径下的共享库的变动即时生效,不用执行ldconfig。就算缓存ldconfig -p 中没有,新加入的动态库也可以执行。
    
5.2.8.3 QtCreator桌面快捷方式

编译版本的QtCreator缺少快捷方式文件,故从已经安装QtCreator的x86Linux上复制文件DigiaQt-qtcreator-Community.desktop到对所有用户生效的/usr/share/applications目录下(类似的目录还有/usr/local/share/applications/、指定用户的/root/.local/share/applications/、~/.local/share/applications/),稍许调整即可。内容如下:

[Desktop Entry]
Type=Application
Exec=/opt/QtCreator/bin/qtcreator
Name=Qt Creator (Community)
GenericName=The IDE of choice for Qt development.
Icon=/opt/QtCreator/share/icons/hicolor/512x512/apps/QtProject-qtcreator.png
StartupWMClass=qtcreator
Terminal=false
Categories=Development;IDE;Qt;
MimeType=text/x-c++src;text/x-c++hdr;text/x-xsrc;application/x-designer;application/vnd.qt.qmakeprofile;application/vnd.qt.xml.resource;text/x-qml;text/x-qt.qml;text/x-qt.qbs;

桌面创建软链接:

# cd /root/桌面
# ln -s /usr/share/applications/DigiaQt-qtcreator-Community.desktop QtCreator.desktop

DigiaQt-qtcreator-Community.desktop文件或桌面QtCreator快捷方式右键属性–>权限–>“允许作为程序执行文件”勾选。桌面图标恢复正常显示。

6 开发库

6.1 CMake

CentOS7.6x64中默认不包括Cmake环境,必须源码编译安装Cmake。由于开发使用的三方库源码工程是Cmake工程,要求3.15以上的Cmake,去Cmake官网下载cmake-3.15.7.tar.gz。(由于已经具有Qt环境,也可以编个带Qt GUI的CMake,方便使用)

  1. 解压

     # tar -zxvf cmake-3.15.7.tar.gz
    
  2. 编译前配置

     # cd cmake-3.15.7/
     # ./configure --qt-gui
    
  3. 编译

     # nohup gmake >> CMakeBuild.log
    
  4. 安装

    # gmake install
    

6.2 Protobuf

源码包:protobuf-all-3.17.3.zip,在源码解压目录下,执行以下:

6.2.1 Debug版

	# cd cmake
	# mkdir build
	# cd build
	# mkdir debug
	# cd debug
	# cmake -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Debug -Dprotobuf_BUILD_SHARED_LIBS=ON ../..
	(以上为一行命令)
	# make -j 8
	# make check
	# make install

6.2.2 Release版

删除原有的源码解压文件夹,重新解压并进入源码解压目录下,执行如下:

	# cd cmake
	# mkdir build
	# cd build
	# mkdir release
	# cd release
	# cmake -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Release -Dprotobuf_BUILD_SHARED_LIBS=ON ../..
	(以上为一行命令)
	# make -j 8
	# make check
	# make install

6.3 Python3.6.5

Python官网下载源码包Python-3.6.5.tgz。

6.3.1 依赖安装

# yum -y install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gdbm-devel db4-devel libpcap-devel xz-devel libffi-devel

6.3.2 编译安装

#  tar -zxvf Python-3.6.5.tgz
#  cd Python-3.6.5/
# ./configure --prefix=/opt/python36
# make -j 8
# make install

6.3.3 建立软链接

# ln -s /opt/python36/bin/python3.6 /usr/bin/python3
# ln -s /opt/python36/bin/pip3.6 /usr/bin/pip3

6.3.4 测试

[root@localhost ThirdPart]# python3
Python 3.6.5 (default, Oct 27 2021, 16:41:46) 
[GCC 7.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> 

6.4 SVN客户端

# yum  -y install subversion

依赖关系解决

Package 架构 版本 源 大小

=================================================
正在安装:
subversion aarch64 1.7.14-16.el7 base 1.0 M
为依赖而安装:
apr aarch64 1.4.8-7.el7 base 97 k
apr-util aarch64 1.5.2-6.el7 base 89 k
subversion-libs aarch64 1.7.14-16.el7 base 851 k
事务概要 ==========================================
安装 1 软件包 (+3 依赖软件包)

7 其它

7.1 Qt应用程序无法输入中文解决方法

修改/etc/X11/xinit/xinput.d/ibus.conf,末尾添加

QT_IM_MODULE=ibus

8 附录QEMU命令与参数

以下为参考材料(参考列表中以注明)

8.1 QEMU常用命令

  1. 创建一个镜像
    qemu-img create test1.raw 2G
    默认创建的为raw格式镜像,如果需要指定qcow2
    qemu-img create test2.qcow2 -f qcow2 2G
    -f 指定镜像格式,默认为raw

  2. 镜像信息查看
    qemu-img info test1.raw
    qemu-img info test2.qcow2

  3. 镜像格式转换

    raw:默认格式,不支持快照功能。镜像大小可以增大缩小
    qcow2:支持快照,镜像只能增大,不能缩小
    qemu-img convert -p -f raw -O qcow2 test1.raw test1.qcow2
    qemu-img info test1.qcow2
    -p 显示转换进度,-f 原有镜像格式,-O 输出镜像格式 输入文件 输出文件
    主要用于将不同虚拟化产品的虚拟机镜像格式进行转换,例如VMware的vmdk转换成kvm用的qcow2格式

  4. 镜像快照
    raw不支持快照,只有qcow2支持快照
    qemu-img snapshot test1.qcow2 -c s1
    -c 参数创建,后接快照名字
    快照查看,使用-l参数
    qemu-img snapshot test1.qcow2 -l
    删除快照,使用-d参数
    qemu-img snapshot test1.qcow2 -d s1
    还原快照,使用-a参数
    qemu-img snapshot test1.qcow2 -a s1
    快照单独提取镜像,可以使用convert参数
    qemu-img convert -f qcow2 -O qcow2 -s s1 test1.qcow2 test-s1.qcow2
    -f 制定快照格式,-O 输出快照格式,-s 快照名字 输入文件,输出文件

  5. 镜像一致性检查
    qemu-img check test1.qcow2

  6. 镜像大小修改
    1,raw格式
    qemu-img resize test1.raw +2G
    增加大小
    qemu-img resize test1.raw 3G
    指定大小
    2,qcow2格式
    raw格式镜像大小都可以调整,qcow2格式镜像只能增大,不能缩小
    qemu-img resize test2.qcow2 +2G
    尝试缩小,报错
    注:有快照的qcow2镜像,不能改变大小.

8.2 QEMU参数

	qemu-system-aarch64.exe	二进制文件,提供模拟aarch64架构的虚拟机进程
	-m 2048	分配2048MB内存
	-M virt	模拟成什么服务器,我们一般选择virt就可以了,他会自动选择最高版本的virt
	-cpu cortex-a72	模拟成什么CPU,其中cortex-a53\a57\a72都是ARMv8指令集的
	-smp  2,cores=2,threads=1,sockets=1	2个vCPU,这2个vCPU由qemu模拟出的一个插槽(socket)中的2个核心,每个核心支持一个超线程构成。
	-bios xxx	指定bios bin所在的路径
	-device xxx	添加一个设备,参数可重复
	-drive	添加一个驱动器,参数可重复
	-net	添加网络设备
	-net nic -net tap	将开发板网卡和主机网卡建立桥接(Bridge)

8.3 Drive参数

drive参数很简单,可以理解成是定义了一个实际的硬盘(或者是cd)与drive对应的是device-drive option[,option[,option[,…]]]
Define a new drive. This includes creating a block driver node (the backend) as well as a guest device, and is mostly a shortcut for defining the corresponding-blockdev and -device options.
定义一个新的驱动,包括后端的驱动节点(可以理解成后端具体的设备)还有guest文件系统中的一个具体的设备。
-driveaccepts all options that are accepted by-blockdev. In addition, it knows the following options:
file=file
This option defines which disk image (see disk_images) to use with this drive. If the filename contains comma, you must double it (for instance, “file=my,file” to use file “my,file”).
Special files such as iSCSI devices can be specified using protocol specific URLs. See the section for “Device URL Syntax” for more information.
if=interface
This option defines on which type on interface the drive is connected. Available types are: ide, scsi, sd, mtd, floppy, pflash, virtio, none.
bus=bus,unit=unit
These options define where is connected the drive by defining the bus number and the unit id.
index=index
This option defines where is connected the drive by using an index in the list of available connectors of a given interface type.
media=media
This option defines the type of the media: disk or cdrom.
cyls=c,heads=h,secs=s[,trans=t]
These options have the same definition as they have in-hdachs. These parameters are deprecated, use the corresponding parameters of -device instead.
snapshot=snapshot
snapshot is “on” or “off” and controls snapshot mode for the given drive (see-snapshot).
cache=cache
cache is “none”, “writeback”, “unsafe”, “directsync” or “writethrough” and controls how the host cache is used to access block data. This is a shortcut that sets thecache.directandcache.no-flushoptions (as in-blockdev), and additionallycache.writeback, which provides a default for thewrite-cacheoption of block guest devices (as in-device). The modes correspond to the following settings:
│ cache.writeback cache.direct cache.no-flush
─────────────┼─────────────────────────────────────────────────
writeback │ on off off
none │ on on off
writethrough │ off off off
directsync │ off on off
unsafe │ on off on
The default mode iscache=writeback.
aio=aio
aio is “threads”, or “native” and selects between pthread based disk I/O and native Linux AIO.
format=format
Specify which disk format will be used rather than detecting the format. Can be used to specify format=raw to avoid interpreting an untrusted format header.
serial=serial
This option specifies the serial number to assign to the device. This parameter is deprecated, use the corresponding parameter of -device instead.
addr=addr
Specify the controller’s PCI address (if=virtio only). This parameter is deprecated, use the corresponding parameter of -device instead.
werror=action,rerror=action
Specify which action to take on write and read errors. Valid actions are: “ignore” (ignore the error and try to continue), “stop” (pause QEMU), “report” (report the error to the guest), “enospc” (pause QEMU only if the host disk is full; report the error to the guest otherwise). The default setting iswerror=enospcandrerror=report.
copy-on-read=copy-on-read
copy-on-read is “on” or “off” and enables whether to copy read backing file sectors into the image file.
bps=b,bps_rd=r,bps_wr=w
Specify bandwidth throttling limits in bytes per second, either for all request types or for reads or writes only. Small values can lead to timeouts or hangs inside the guest. A safe minimum for disks is 2 MB/s.
bps_max=bm,bps_rd_max=rm,bps_wr_max=wm
Specify bursts in bytes per second, either for all request types or for reads or writes only. Bursts allow the guest I/O to spike above the limit temporarily.
iops=i,iops_rd=r,iops_wr=w
Specify request rate limits in requests per second, either for all request types or for reads or writes only.
iops_max=bm,iops_rd_max=rm,iops_wr_max=wm
Specify bursts in requests per second, either for all request types or for reads or writes only. Bursts allow the guest I/O to spike above the limit temporarily.
iops_size=is
Let every is bytes of a request count as a new request for iops throttling purposes. Use this option to prevent guests from circumventing iops limits by sending fewer but larger requests.
group=g
Join a throttling quota group with given name g. All drives that are members of the same group are accounted for together. Use this option to prevent guests from circumventing throttling limits by using many small disks instead of a single larger disk.
By default, thecache.writeback=onmode is used. It will report data writes as completed as soon as the data is present in the host page cache. This is safe as long as your guest OS makes sure to correctly flush disk caches where needed. If your guest OS does not handle volatile disk write caches correctly and your host crashes or loses power, then the guest may experience data corruption.
For such guests, you should consider usingcache.writeback=off. This means that the host page cache will be used to read and write data, but write notification will be sent to the guest only after QEMU has made sure to flush each write to the disk. Be aware that this has a major impact on performance.
When using the-snapshotoption, unsafe caching is always used.
Copy-on-read avoids accessing the same backing file sectors repeatedly and is useful when the backing file is over a slow network. By default copy-on-read is off.
Instead of-cdromyou can use:
qemu-system-i386 -drive file=file,index=2,media=cdrom
Instead of-hda,-hdb,-hdc,-hdd, you can use:
qemu-system-i386 -drive file=file,index=0,media=disk
qemu-system-i386 -drive file=file,index=1,media=disk
qemu-system-i386 -drive file=file,index=2,media=disk
qemu-system-i386 -drive file=file,index=3,media=disk
You can open an image using pre-opened file descriptors from an fd set:
qemu-system-i386
-add-fd fd=3,set=2,opaque=“rdwr:/path/to/file”
-add-fd fd=4,set=2,opaque=“rdonly:/path/to/file”
-drive file=/dev/fdset/2,index=0,media=disk
You can connect a CDROM to the slave of ide0:
qemu-system-i386 -drive file=file,if=ide,index=1,media=cdrom
If you don’t specify the “file=” argument, you define an empty drive:
qemu-system-i386 -drive if=ide,index=1,media=cdrom
Instead of-fda,-fdb, you can use:
qemu-system-i386 -drive file=file,index=0,if=floppy
qemu-system-i386 -drive file=file,index=1,if=floppy
By default, interface is “ide” and index is automatically incremented:
qemu-system-i386 -drive file=a -drive file=b"
is interpreted like:
qemu-system-i386 -hda a -hdb b

8.4 qemu使用实例和常用参数

qemu使用实例参数详解:

qemu.exe -kernel-kqemu -L . -m 512 -hda f:\system-virtual\windowsxp\windowsxp.vmdk -cdrom
e:\my-lab\iso\windowsxp-en.iso -boot d

-kernel-kqemu 加快qemu速度 
-m 512 为虚拟机分配512m内存 
-hda f:\system-virtual\windowsxp\windowsxp.vmdk 系统安装到哪里去,就安装到刚才建立的虚拟磁盘文件中去 
-cdrom e:\my-lab\iso\windowsxp-en.iso 为qemu的虚拟光驱中插入光盘镜像 
-boot d 设置qemu的BIOS由光驱启动. 

qemu.exe

 -m 512 
 -net nic,model=ne2k_pci 
 -net nic,model=pcnet 
 -soundhw ac97,pcspk 
 -usb -parallel none -serial none 
 -hda winxp.img 
 -hdb h: 
 -fda fdboot.img 
 -cdrom bootcd.iso 
 -rtc base=2009-01-01T16:00:21 
 -vnc 127.0.0.1:0 
 -net user,hostfwd=tcp::5555-:23 
 -boot menu=on 

以上命令模拟了一台

含有512兆内存
2个不同的网络卡
1个ac97声卡1个PC 喇叭的电脑。 
它支持USB没有并口和串口
有2块硬盘第一硬盘使用安装有windows xp的winxp.img映像第二硬盘使用宿主电脑的h分区只读
1个载入FreeDOS的软驱
1台载入bootcd.iso的光驱。 
这台电脑的时间设定为2009年一月一日16点21秒
特殊的是这台模拟电脑必须通过VNC软件控制 
并且将模拟电脑的23号端口telnet)转发到宿主电脑的5555端口 
在模拟电脑启动的时候有一个菜单选择要启动的设备。

qemu常用参数列表:

全部参数文档地址:

http://qemu.weilnetz.de/qemu-doc.html

-h:帮助

-version:查看版本
-M machine:选择虚拟机

-fda file:
-fdb file:使用文件作为软盘,可以使用主机的“/dev/fd0”

-hda file:硬盘选项
-hdb file:硬盘选项
-hdc file:硬盘选项
-hdd file:硬盘选项

-cdrom file:光驱选项

-drive option[,option[,option[,…]]]:定义一个新的驱动器,有效选项如下:

 file=file:定义镜像文件
 if=interface:该选项定义驱动被连接的类型,ide, scsi, sd, mtd, floppy, pflash, virtio.
 bus=bus,unit=unit:这些选项定义连接的驱动器定义总线数字和单位ID。
 index=index:此选项定义驱动器连接在一个给定的接口类型列表中可用的连接器使用索引。(可能为盘符)
 media=media:cdrom还是disk
 cyls=c,heads=h,secs=s[,trans=t]:选项同‘-hdachs’
 snapshot=snapshot:值为"on" or "off",允许被给的驱动器使能snapshot
 cache=cache:值为"none", "writeback", or "writethrough" ,控制主机缓存用于访问数据块
 aio=aio:值为"threads", or "native" ,选择线程基于磁盘IO还是本地linux IO
 format=format:指定磁盘格式,建议使用raw
 serial=serial:给设备指定序列号(可能是串口,也可能和串口无关)
 addr=addr:指定PCI地址(仅仅:if=virtio)
    默认情况下,连续写入缓存被用于所有的块设备,这意味着主机页缓存将被用于读和写数据,但是仅仅当数据被报知被写入存储子系统,写通知将被发送到客户机。
    Instead of ‘-cdrom’ you can use:qemu -drive file=file,index=2,media=cdrom
    Instead of ‘-hda’, ‘-hdb’, ‘-hdc’, ‘-hdd’, you can use:
 qemu -drive file=file,index=0,media=disk
 qemu -drive file=file,index=1,media=disk
 qemu -drive file=file,index=2,media=disk
 qemu -drive file=file,index=3,media=disk

-boot:启动选项,软盘(a)、硬盘(c)、光驱(D)、网卡(n),默认是从硬盘启动

-snapshot:快照功能

-no-fd-bootchk:禁止启动检测软盘

-m megs:内存大小

-cpu model:选择cpu模式

-smp n:cpu个数

-numar opts:模拟一个多节点的非统一内存访问,如果cpu内存都被忽略,资源平分

-nographic:通常,QEMU使用SDL显示VGA输出,使用这个选项,使qemu成为简单的命令行应用程序

-k language:键盘布局,默认是en-us

-audio-help:声音子系统帮助显示,驱动列表,可调参数等

-soundhw card1,card2,... or -soundhw all:使能音频并选择声卡

-localtime:设置真实时钟为本地时钟,默认是UTC时间

-full-screen:全屏

-pidfile file:存储qemu进程PID到文件,用于脚本启动

-daemonize:初始化后QEMU进程长期驻留,qemu将不从标准IO分离,除非他准备连接到他的设备中的起其中一个。这个选项用于外部程序启动qemu而不用去初始化静态条件。

-option-rom file:加载一个可选ROM文件内容,用于加载像EtherBoot这样的东西。

-mtdblock file:

USB选项:

-usb:使能usb驱动,默认项
-usbdevice devname:添加usb设备名称,有效的设备如下:
 mouse:虚拟鼠标,会覆盖ps/2鼠标仿真
 tablet:使用绝对坐标的指针设备(如:触摸屏),也会覆盖ps/2鼠标
 disk:file:基于文件的大容量存储设备
 host:bus.addr:通过总线地址传递主机设备(仅仅linux平台有效)
 host:vendor_id:product_id:通过pid、vid传递主机设备(仅仅linux平台有效)

Network options: (网络这里先不做重点)

-net nic[,vlan=n][,macaddr=addr][,model=type]:
-net user[,vlan=n][,hostname=name]:
-net tap[,vlan=n][,fd=h][,ifname=name][,script=file]:
-net socket[,vlan=n][,fd=h][,listen=[host]:port][,connect=host:port]:
-net socket[,vlan=n][,fd=h][,mcast=maddr:port]:
-net none:
-tftp prefix:
-smb dir:
-redir [tcp|udp]:host-port:[guest-host]:guest-port:重定向网络

-kernel bzImage: 内核镜像
-append cmdline:内核命令行

-initrd file:使用文件作为ram盘

Debug/Expert options:

-serial dev:重定向虚拟串口到主机设备。默认设备是vc在图形模式下,是stdio在非图形界面。这个选项可被使用多次,可模拟4个串口。使用-serial none会屏蔽所有串口。有效的字符设备是:
 vc:虚拟控制台
 pty:仅仅linux有效,虚拟tty(一个虚拟伪终端会被立刻分配)
 none:没有设备被分配
 null:无效设备
 /dev/XXX:仅仅linux有效,使用主机tty,e.g. `/dev/ttyS0'. 
 /dev/parportN:仅仅linux有效,使用主机并口N,当前仅仅SPP(串行式)特征能被使用。
 file:filename:写输出到filename,没有字符被读
 stdio:仅仅unix可用
 pipe:filename:命名管道
 COMn:仅仅windows可用,使用主机串口n
 udp:[remote_host]:remote_port[@[src_ip]:src_port]:这实现了UDP网络控制台,当远程主机(remote_host)或源ip(src_ip)未指定

,则会被默认设置为0.0.0.0。当未使用源端口(src_port)
tcp:[host]:port[,server][,nowait][,nodelay]:TCP网络控制方式有两种模式。可以发送串口I/O到一个位置或等待一个连接。默认情况下,TCP网络控制台通过port发送主机。
Example to send tcp console to 192.168.0.2 port 4444 
-serial tcp:192.168.0.2:4444 
Example to listen and wait on port 4444 for connection 
-serial tcp::4444,server 
Example to not wait and listen on ip 192.168.0.100 port 4444 
-serial tcp:192.168.0.100:4444,server,nowaittelnet:host:port[,server][,nowait][,nodelay]:telnet协议是用来代替原始的tcp协议,这个选项工作类似于-serial tcp。

unix:path[,server][,nowait]:使用unix域套接字代替tcp套接字,这个选项工作类似于-serial tcp。

-parallel dev:重定向虚拟并口到主机设备。最多可虚拟3个并口。

9 参考资料

【1】GNU Toolchain - Confluence (atlassian.net)
【2】QEMU - Confluence (atlassian.net)
【3】qemu的常用命令【图文】_gaoyan0320_51CTO博客
【4】qemu-img命令详解_Better Me的博客-CSDN博客
【5】QEMU 安装指南_鲲鹏DevKit_鲲鹏论坛_华为云论坛 (huaweicloud.com)
【6】qemu使用实例和常用参数_whatday的专栏-CSDN博客_qemu参数
【7】qemu的drive参数解释 - honpey - 博客园 (cnblogs.com)
【8】鲲鹏服务器实验一:GCC编译安装_鲲鹏论坛_华为云论坛 (huaweicloud.com)
【9】GCC, the GNU Compiler Collection - GNU Project.GCC官网.
【10】(3条消息) CentSO安装build-essential_eonun技术分享点-CSDN博客
【11】(3条消息) 在Centos上安装build essentials_huobanjishijian的专栏-CSDN博客
【12】qt-everywhere-src-5.13.1.README
【13】qt-creator-opensource-src-4.10.0.README.md
【14】Qt-configure配置选项_xqhrs232的专栏-CSDN博客
【15】CentOS7安装epel的方式 - 凌空a - 博客园 (cnblogs.com)
【16】How to install Clang and LLVM 3.9 on CentOS 7 - Stack Overflow
【17】Qt 5.13.0编译移植指导 for centos 7.6 ★★★_迁移调优实践_鲲鹏论坛_华为云论坛 (huaweicloud.com)
【18】Qt-5.13 编译移植指导 for 鲲鹏CentOS-7.6 补充QtWebEngine_鲲鹏论坛_华为云论坛 (huaweicloud.com)
【19】Qt 5.13.0编译移植指导 for Ubuntu 18.04.3【鲲鹏920(ARM64)】_鲲鹏论坛_华为云论坛 (huaweicloud.com)
【20】QT5.6编译./configure参数的详细解释_qing666888的专栏-CSDN博客
【21】Linux编译安装Qt 5.4.1(-qt-xcb是必须要指定的,卸载自带的gcc等) - findumars - 博客园 (cnblogs.com)
【22】(5条消息) yum 安装后保留rmp安装包_archer的技术故事-CSDN博客
【23】(5条消息) linux arm下安装mysql_jiongsui7605的博客-CSDN博客
【24】(5条消息) Centos7 安装mysql 8.0.13(rpm)的步骤,就看这一篇就可以。_全冉 的博客-CSDN博客
【25】protobuf/README.md at master • protocolbuffers/protobuf • GitHub
【26】ldconfig , ldd 与 LD_LIBRARY_PATH 之间的关系 - stardsd - 博客园 (cnblogs.com)
  • 1
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值