1

我正在尝试在我的 ubuntu 服务器中设置 libvirt-php 以使用 PHP API 进行一些测试。我正在遵循这个程序:

sudo apt-get install libvirt-dev xsltproc libxml2-dev libxml2  
cd ~ 
git clone git://libvirt.org/libvirt-php.git libvirt-php  
cd libvirt-php  
sudo sh autogen.sh  
sudo ./configure  
sudo make  
sudo make install  
sudo service apache2 restart

我还为 ubuntu 安装了 php5-dev 和 xmllint 包,但是当我转到第 7 行时:让我得到这些错误:

make  all-recursive
make[1]: Entering directory `/root/libvirt-php'
Making all in tools
make[2]: Entering directory `/root/libvirt-php/tools'
gcc -Wall -o generate-api-docs generate-api-docs.c
./generate-api-docs ../src/libvirt-php.c ../docs/api-reference.html.in
Documentation has been generated successfully
./generate-api-docs --private ../src/libvirt-php.c ../docs/dev-api-reference.html.in
Documentation has been generated successfully
make[2]: Leaving directory `/root/libvirt-php/tools'
Making all in src
make[2]: Entering directory `/root/libvirt-php/src'
gcc -g -O2 -Wall -fpic -DCOMPILE_DL_LIBVIRT=1 -I/usr/include/php5 -I/usr/include/php5/main -I/usr/include/php5/TSRM -I/usr/include/php5/Zend -I/usr/include/php5/ext -I/usr/include/php5/ext/date/lib -c -o libvirt-php.o libvirt-php.c -I/usr/include/libxml2    -DHAVE_CONFIG_H
libvirt-php.c: In function ‘zm_startup_libvirt’:
libvirt-php.c:1149:2: error: ‘VIR_DOMAIN_VCPU_GUEST’ undeclared (first use in this function)
libvirt-php.c:1149:2: note: each undeclared identifier is reported only once for each function it appears in
libvirt-php.c: In function ‘zif_libvirt_domain_get_metadata’:
libvirt-php.c:3240:2: warning: implicit declaration of function ‘virDomainGetMetadata’ [-Wimplicit-function-declaration]
libvirt-php.c:3240:6: warning: assignment makes pointer from integer without a cast [enabled by default]
libvirt-php.c: In function ‘zif_libvirt_domain_set_metadata’:
libvirt-php.c:3285:2: warning: implicit declaration of function ‘virDomainSetMetadata’ [-Wimplicit-function-declaration]
libvirt-php.c: In function ‘zif_libvirt_connect_get_soundhw_models’:
libvirt-php.c:4135:8: warning: ignoring return value of ‘fgets’, declared with attribute warn_unused_result [-Wunused-result]
libvirt-php.c: In function ‘zif_libvirt_connect_get_nic_models’:
libvirt-php.c:4064:8: warning: ignoring return value of ‘fgets’, declared with attribute warn_unused_result [-Wunused-result]
libvirt-php.c: In function ‘zif_libvirt_domain_get_screenshot_api’:
libvirt-php.c:3564:9: warning: ignoring return value of ‘system’, declared with attribute warn_unused_result [-Wunused-result]
libvirt-php.c: In function ‘zif_libvirt_image_create’:
libvirt-php.c:2172:8: warning: ignoring return value of ‘system’, declared with attribute warn_unused_result [-Wunused-result]
make[2]: *** [build] Error 1
make[2]: Leaving directory `/root/libvirt-php/src'
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory `/root/libvirt-php'
make: *** [all] Error 2

所以我无法编译。有什么帮助吗?

4

1 回答 1

0

在 git://libvirt.org/libvirt-php 中写的要求版本似乎不正确

它显示LIBVIRT_REQUIRED=0.6.2,但在 Ubuntu 12.04 使用的版本 0.9.8 中,变量virDomainGetMetadataVIR_DOMAIN_VCPU_GUEST未定义,导致此错误。

(如果您想查询您的 libvirt-dev 版本,请输入 $ dpkg-query -s libvirt-dev

你可以试试这个:

  1. 升级你的 Ubuntu

    最新版本的 Ubuntu 支持具有变量的新 libvirt-devvirDomainGetMetadata

    https://launchpad.net/ubuntu/+source/libvirt

  2. 使用 libvirt-php 0.4.8

    我用它来解决问题,但出现了另一个问题,它不支持 libvirt_domain_get_metadata.

    以下步骤展示了如何使用 libvirt-php 0.4.8:

    访问http://libvirt.org/php/downloads.html

    $wget http://libvirt.org/sources/php/libvirt-php-0.4.8.tar.gz
    $tar -xvf libvirt-php-0.4.8.tar.gz
    $cd libvirt-php-0.4.8
    $./configure
    $make
    

    然后检查没有其他问题

    $sudo make install
    $sudo /etc/init.d/apache2 restart
    
于 2014-01-12T19:18:46.407 回答