簡體   English   中英

在Ubuntu Server 12.04上編譯libvirt-php時出錯

[英]Error compiling libvirt-php on Ubuntu Server 12.04

我正在嘗試在我的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

所以我不能編譯。 有什么幫助嗎?

在git://libvirt.org/libvirt-php中編寫的require版本似乎不正確

它顯示LIBVIRT_REQUIRED=0.6.2 ,但是在版本0.9.8中(使用Ubuntu 12.04的版本中)未定義變量virDomainGetMetadataVIR_DOMAIN_VCPU_GUEST ,這導致此錯誤。

(如果要查詢您的libvirt-dev版本,請輸入$ dpkg-query -s libvirt-dev

您可以嘗試以下方法:

  1. 升級您的Ubuntu

    最新版本的Ubuntu支持具有變量virDomainGetMetadata新libvirt-dev

    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 

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM