编译libvirt,并gdb

来源:互联网 发布:苹果远程连接软件 编辑:程序博客网 时间:2024/06/06 12:39

好久没有碰libivrt了,以前也没有总结下来。所以重新开始编辑libvirt和gdb


本来想直接用 debuginfo-install libvirt    安癍debug版的libivrt,结果没找到包,那就算了吧,重新编译个也不错。


编译过程中会出现如果错误,以前要来装的包,同时如果要编译debug版本的需要带上 --enable-debug=yes

[root@nova02 libvirt-1.2.17]# ./configure --help | grep debug  --enable-debug=[no|yes] enable debugging output [default=yes]


中途出现的问题如下:

1、configure: error: You must install the libyajl library & headers to compile libvirt
解决方案:yum install libxml2.x86_64  yum install libxml2-devel.x86_64
              yum install yajl.x86_64 yajl-devel.x86_64


2、configure: error: You must install device-mapper-devel/ >= 1.0.0 to compile libvirt
解决方案:yum install device-mapper-devel


3、configure: error: You must install the pciaccess module to build with udev
解决方案:yum install libpciaccess-devel.x86_64
 

4、configure: error: libnl-devel >= 1.1 is required for macvtap support
解决方案:yum install libnl-devel.x86_64



所以总的安装步骤如下:

1. 安装编译工具和依赖包# yum -y install gcc yajl-devel libxml2-devel device-mapper-devel libpciaccess-devel libnl-devel


2. 下载源码、编译安装# wget http://libvirt.org/sources/libvirt-1.2.17.tar.gz# tar -zxf libvirt-1.2.17.tar.gz# cd libvirt-1.2.17# ./configure --enable-debug=yes --prefix=/usr# make# make install
ldconfig

3. 确认安装成功# which libvirtd# virsh version# libvirtd --version


cp tools/virsh /usr/bin/virsh

ln -s /usr/local/var/run/libvirt/libvirt-sock /var/run/libvirt/libvirt-sock



如果要使用gdb 调试代码需要在编译是加上  --enable-debug=yes

如果需要 libvirt 支持numa,在编译时要加上   --with-numactl


libvirt里有很多宏,在gdb打印宏的时候会报   

(gdb) p LIBVIRT_SETUID_RPC_CLIENT

No symbol "LIBVIRT_SETUID_RPC_CLIENT" in current context.


如果想要打印宏,在编译时需要加上  需要加入-g3 和-gdwarf-2



原创粉丝点击