2010-02-15 31 views
4

我在XP平臺上編譯了一些PHP擴展庫(使用C/C++)。我現在已經將源代碼移到我的Ubuntu盒子中,並且想要構建在我的Linux機器上使用的庫。在Ubuntu上編譯PHP擴展庫(Karmic Koala)

不過,我來翻過了一些障礙:

  1. 我不能找到phpize
  2. 我找不到ext_skel生成骨架腳本/文件(即使安裝php5dev包後)

[編輯]

感謝帕斯卡·馬丁和this question,我有馬用來建立和測試我的一個小型圖書館。我只想仔細檢查我的.m4文件的內容(因爲我對格式不熟悉),然後繼續處理其他庫。

這是自動生成的.m4文件的內容 - 任何熟悉格式的人都可以解釋它的含義 - 這樣我可以更加確定我已經取消註釋了文件的正確部分。

的的config.m4文件的內容顯示在下面的所有血腥的細節:

dnl $Id$ 
dnl config.m4 for extension tanlib 

dnl Comments in this file start with the string 'dnl'. 
dnl Remove where necessary. This file will not work 
dnl without editing. 

dnl If your extension references something external, use with: 

dnl PHP_ARG_WITH(tanlib, for tanlib support, 
dnl Make sure that the comment is aligned: 
dnl [ --with-tanlib    Include tanlib support]) 

dnl Otherwise use enable: 

PHP_ARG_ENABLE(tanlib, whether to enable tanlib support, 
dnl Make sure that the comment is aligned: 
[ --enable-tanlib   Enable tanlib support]) 

if test "$PHP_TANLIB" != "no"; then 
    dnl Write more examples of tests here... 

    dnl # --with-tanlib -> check with-path 
    dnl SEARCH_PATH="/usr/local /usr"  # you might want to change this 
    dnl SEARCH_FOR="/include/tanlib.h" # you most likely want to change this 
    dnl if test -r $PHP_TANLIB/$SEARCH_FOR; then # path given as parameter 
    dnl TANLIB_DIR=$PHP_TANLIB 
    dnl else # search default path list 
    dnl AC_MSG_CHECKING([for tanlib files in default path]) 
    dnl for i in $SEARCH_PATH ; do 
    dnl  if test -r $i/$SEARCH_FOR; then 
    dnl  TANLIB_DIR=$i 
    dnl  AC_MSG_RESULT(found in $i) 
    dnl  fi 
    dnl done 
    dnl fi 
    dnl 
    dnl if test -z "$TANLIB_DIR"; then 
    dnl AC_MSG_RESULT([not found]) 
    dnl AC_MSG_ERROR([Please reinstall the tanlib distribution]) 
    dnl fi 

    dnl # --with-tanlib -> add include path 
    dnl PHP_ADD_INCLUDE($TANLIB_DIR/include) 

    dnl # --with-tanlib -> check for lib and symbol presence 
    dnl LIBNAME=tanlib # you may want to change this 
    dnl LIBSYMBOL=tanlib # you most likely want to change this 

    dnl PHP_CHECK_LIBRARY($LIBNAME,$LIBSYMBOL, 
    dnl [ 
    dnl PHP_ADD_LIBRARY_WITH_PATH($LIBNAME, $TANLIB_DIR/lib, TANLIB_SHARED_LIBADD) 
    AC_DEFINE(HAVE_TANLIBLIB,1,[ Whether you have tanlib]) 
    dnl ],[ 
    dnl AC_MSG_ERROR([wrong tanlib lib version or lib not found]) 
    dnl ],[ 
    dnl -L$TANLIB_DIR/lib -lm -ldl 
    dnl ]) 
    dnl 
    dnl PHP_SUBST(TANLIB_SHARED_LIBADD) 

    PHP_NEW_EXTENSION(tanlib, tanlib.c, $ext_shared) 
fi 

有誰神交以上? 。

BTW,使用的Autoconf 2.50生成以上的config.m4文件(我也剛剛看到的文檔here和我慢慢消化它

+0

你有沒有安裝php devel軟件包? – Neel

回答

2

在我的Ubuntu電腦,phpize是:

$ which phpize 
/usr/bin/phpize 


ext_skel應該在「ext」目錄,在PHP源,您可以通過SVN得到。

這裏是ext目錄:http://svn.php.net/viewvc/php/php-src/trunk/ext/
而且您可以查看腳本here的內容。

README.EXT_SKEL剛好在trunk/之下。


如果你是一個多用戶的git的,有SVN的GitHub上鏡:http://github.com/php/

+0

感謝帕斯卡爾,你的鏈接和RaC上的另一個問題幫助我建立它。我幾乎在那裏(請參閱編輯的問題) –

+0

@粘貼到男人:對不起,但我不會對.m4的東西有任何幫助:我從來沒有嘗試過(好,但^^)開發一個PHP擴展,我更像是一個PHP開發人員而不是C/C++開發人員。祝你好運,無論如何:-) –

0

要回答你的後續問題,dnl是行註釋標記在.m4文件,所以這些線路目前沒有做任何事情。這很可能是正確的,因爲如果您使用的是外部庫(並且通過使用--with-myextension配置選項而不是--enable-myextension),它們通常只與相關。

上述文件(修訂版3)因此等效於:

PHP_ARG_ENABLE(tanlib, whether to enable tanlib support, 
[ --enable-tanlib   Enable tanlib support]) 

if test "$PHP_TANLIB" != "no"; then 
    AC_DEFINE(HAVE_TANLIBLIB,1,[ Whether you have tanlib]) 
    PHP_NEW_EXTENSION(tanlib, tanlib.c, $ext_shared) 
fi 

因此,如果您在此目錄中之後,它應該工作(我想,我沒有合適的Linux機手進行檢查):

phpize 
./configure --enable-tanlib 
make 
make install 

最後,請確保該擴展是在/etc/php5/conf.d啓用。

請記住,您需要重新啓動apache(sudo /etc/init.d/apache2 restart)以獲取任何擴展更改。

+0

謝謝,我已經在前一段時間瞭解到了這一點。我設法建立了擴展庫 - 儘管由於某種原因,這些符號沒有被導出(但是這是一個不同的問題) –