本文主要记录spice客户端的编译安装相关问题。
为了能够在普通的PC机上正常使用,以下的一些安装包是必须的:
Windows的安装就不赘述了,没什么难度,双击安装就搞定了。
本文的安装环境为CentOS7虚拟机,本文记录从一个全新的CentOS开始。
要保证spice的正常安装,要保证该客户端已经进行更新,并且已安装libvirt。
[root@test-spice ~]# yum update //系统内核更新
[root@test-spice ~]# yum install libvirt //安装libvirt
先查看系统中之前安装过哪些跟spice有关的包
[root@test-spice ~]# rpm -qa | grep spice
spice-glib-0.34-3.el7.x86_64
spice-vdagent-0.14.0-15.el7.x86_64
spice-server-0.14.0-2.el7.x86_64
spice-gtk3-0.34-3.el7.x86_64
把这4个包都卸载掉
[root@test-spice ~]# rpm -e --nodeps spice-gtk3
[root@test-spice ~]# rpm -e --nodeps spice-glib
[root@test-spice ~]# rpm -e --nodeps spice-server
[root@test-spice ~]# rpm -e --nodeps spice-vdagent
三部曲(configure、make、make install)安装
[root@test-spice ~]# wget https://www.spice-space.org/download/releases/spice-protocol-0.12.15.tar.bz2
[root@test-spice ~]# tar -xvf spice-protocol-0.12.14.tar.bz2
[root@test-spice ~]# cd spice-protocol-0.12.14/
[root@test-spice spice-protocol-0.12.14]# ./configure --prefix=/usr/local //指定安装目录到/usr/local
[root@test-spice spice-protocol-0.12.14]# make
[root@test-spice spice-protocol-0.12.14]# make install
装好之后记得要把spice-protocol的环境变量引用添加到系统的环境变量中,安装其他东西的时候才能调用到。
[root@test-spice spice-protocol-0.12.14]# cp spice-protocol.pc /usr/lib64/pkgconfig
同上,下载编译安装
【划重点】装好之后把.pc文件拷入/usr/lib64/pkgconfig中。
同上,方法不赘述,但是安装过程中遇到很多问题,在下一章进行记录。编译安装时的最终命令如下:
[root@test-spice spice-gtk-0.35]# ./configure --prefix=/usr/local --disable-opus --disable-shared
configure:
Spice-Gtk 0.35
==============
prefix: /usr/local
c compiler: gcc -std=gnu99
Target: Unix
Gtk: 3.0
Coroutine: ucontext
PulseAudio: no
GStreamer Audio: no
GStreamer Video: no
SASL support: no
Smartcard support: no
USB redirection support: yes
DBus: yes
WebDAV support: no
LZ4 support: no
Now type 'make' to build spice-gtk
【划重点】装好之后把.pc文件拷入/usr/lib64/pkgconfig中
安装完成spice-gtk之后,千万别忘了装virt-viewer,因为spice-gtk只提供一个远程桌面的访问功能,具体窗口显示还是由virt-viewer来提供。
[root@test-spice ~]# wget https://virt-manager.org/download/sources/virt-viewer/virt-viewer-8.0.tar.gz
[root@test-spice ~]# tar -xzf virt-viewer-8.0.tar.gz
[root@test-spice ~]# cd virt-viewer-8.0/
[root@test-spice ~]# ./configure --prefix=/usr/local
[root@test-spice ~]# make
[root@test-spice ~]# make install
安装完成就可以使用virt-viewer的命令来打开访问虚拟机了。
[root@test-spice ~]# remote-viewer
[root@test-spice ~]# yum search gtk3 //有时候安装包的名称和提示的并不完全相同,先查找一下可安装的,安装对应需要的包
[root@test-spice ~]# yum install gtk3-devel.x86_64 //尽量都安装-devel的工具包
安装完成后,再次编译spice即可,如果出现别的缺少和依赖再继续yum instlal即可。
checking for OPUS... no
configure: error: Opus could not be detected, explicitly use --disable-opus if that's intentional
configure: error: ./configure failed for spice-common
[解决方法]
[root@test-spice spice-gtk-0.35]# ./configure --prefix=/usr/local --disable-opus
/bin/ld: /usr/lib/gcc/x86_64-redhat-linux/4.8.5/../../../../lib64/libcrypto.a(bio_asn1.o): relocation R_X86_64_32 against `.rodata.str1.1' can not be used when making a shared object; recompile with -fPIC
[解决方法]
配置时禁用共享,再编译即可。
[root@test-spice spice-gtk-0.35]# ./configure --prefix=/usr/local --disable-opus --disable-shared
[root@test-spice spice-gtk-0.35]# make
[解决方法]
ssl的相关包主要是openssl,spice的传输调用openssl的相关传输加密。因此,仅安装openssl包无法满足spice的调用,需要安装open-devel包。
[root@test-spice spice-gtk-0.35]# yum install openssl-devel.x86_64
[root@test-spice spice-gtk-0.35]# make clean //清理之前编译生成的文件
openssl-devel安装成功后再重新编译安装即可。