Compiling the PHP Extension Library on Ubuntu (Karmic Koala)

I compiled some PHP extension extensions (in C / C ++) some time ago on my XP platform. Now I have moved the sources to my Ubuntu box and want to create libraries for use in my Linux box.

However, I encountered a number of obstacles:

  • I can not find phpize (even after installing php5dev package)
  • I cannot find ext_skel to create a skeleton script / files

[change]

Thanks to Pascal Martin and this question , I was able to create and test one of my smaller libraries. I just want to double check the contents of my .m4 file (since I am not familiar with the format) before I continue working with other libraries.

This is the contents of an auto-generated .m4 file - someone is familiar with the format and can explain what it means - this is so that I can be doubly sure that I uncommented the correct sections of the file.

The contents of the config.m4 file are displayed below in full detail:

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 

Does anyone peek above?

BTW, the above config.m4 file was generated using Autoconf 2.50 (I also just saw the documentation here and slowly digesting it.

+4
source share
2 answers

On my Ubuntu computer, phpize is located in:

 $ which phpize /usr/bin/phpize 


And ext_skel should be in the " ext " directory in PHP sources, which you can get with SVN.

Here's the ext directory: http://svn.php.net/viewvc/php/php-src/trunk/ext/
And here you can view the contents of the script.

README.EXT_SKEL is under trunk/ .


If you are more of a git user, there is an SVN mirror on github: http://github.com/php/

+2
source

To answer your subsequent question, dnl is the line comment marker in .m4 files, so these lines currently do nothing. This is probably normal, since they are mostly applicable only if you use an external library (and by convention, using the --with-myextension configure option rather than --enable-myextension ).

Thus, the above file (starting with version 3) is equivalent to:

 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 

So, if you do the following in this directory, it should work (I think I do not have a suitable Linux machine to check this):

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

Finally, make sure the extension is included in /etc/php5/conf.d .

Remember that you will need to restart apache ( sudo /etc/init.d/apache2 restart ) to get any extension changes.

0
source

Source: https://habr.com/ru/post/1301366/


All Articles