安装环境: Ubuntu12.04 Server
安装包: libvirt-1.0.0
2012.12.22更新:libvirt版本的发布速度很快,不过安装方法基本是不变的,如不想花大把时间看完一下全文,这里总结一点:正确安装libvirt的前提是要有如下依赖包:gcc、make、pkg-config、libxml2-dev、libgnutls-dev、libdevmapper-dev、libcurl4-gnutls(xen)、python-dev(可能早期版本还需要libyajl-dev)
./configure --prefix=/usr --localstatedir=/var --sysconfdir=/etc
configure附上参数可以完成覆盖原有libvirt
第一阶段:
以下操作都是在root模式下使用
Ubuntu缺省情况下,没有提供C/C++的编译环境,所以还需手动安装如下包
sudo apt-get install build-essential
./configure
error: Could not find libxml2 anywhere
apt-get install libxml2 libxml2-dev
error: You must install the GnuTLS library in order to compile and run libvirt
apt-get install gnutls-bin libgnutls-dev
error: You must install device-mapper-devel/libdevmapper >= 1.0.0 to compile libvirt
apt-get install libdevmapper1.02.1 libdevmapper-dev
error: You must install python-devel to build Python bindings
因为libvirt1.0.0中包含有支持python 的库 apt-get install python-dev
error: libnl-devel >= 1.1 is required for macvtap supportapt-get install libnl-dev
安装完libnl-dev后还是报同样的错误,我们安装pkg-config 修改一下以安装的libnl-devel的版本 apt-get install pkg-config pkg-config --modversion libnl-1
第二阶段:
此时基本上没什么错误了,接下来就是 make make install 安装完成后,我们用 virsh list 命令检查libvirt是否可用了 virsh: error while loading shared libraries: libvirt.so.0: cannot open shared object file: No such file or directory有一种可能就是系统第一次在/usr/local下手动编译安装程序,执行ldconfig命令更新动态