Re: [PHP-DEV] PHP / C++ Interaction
Steph Fox wrote: Just search the archives, or the zend weeklies index page (http://www.zend.com/zend/week/) if you're short of time. I remember linking to someone's material regarding C++ extensions for PHP a few months back, and it'll be in the 'item descriptions' there. Yet another shameless plug: CodeGen_PECL (http://pear.php.net/package/CodeGen_PECL/) supports C++ extension writing just fine (including the needed config.m4 magic etc), see e.g.: http://cvs.php.net/viewcvs.cgi/pear/CodeGen_PECL/docs/examples/resource_cpp.xml?view=markup -- Hartmut Holzgraefe, Senior Support Engineer. MySQL AB, www.mysql.com -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DEV] RESOLVED (sort of): [PHP-DEV] PHP / C++ Interaction
George Schlossnagle sent me the following link to a a tutorial by Jay Smith: http://142.166.76.45/software/php5cpp/php5cpp/ This provides full code for a C++ based extension. On a Suse 9.3 distribution of Php5 this results in an (unresolved) error, but with an Apache2/Php5 build from source, the example is fine. Thanks to all, for responses. Cheers, Andrew.
Re: [PHP-DEV] RESOLVED (sort of): [PHP-DEV] PHP / C++ Interaction
Thanks for that, Jay's moved his site since I wrote about it! Updating. - Steph - Original Message - From: Andrew Mather [EMAIL PROTECTED] To: internals@lists.php.net Sent: Monday, February 20, 2006 12:00 PM Subject: [PHP-DEV] RESOLVED (sort of): [PHP-DEV] PHP / C++ Interaction George Schlossnagle sent me the following link to a a tutorial by Jay Smith: http://142.166.76.45/software/php5cpp/php5cpp/ This provides full code for a C++ based extension. On a Suse 9.3 distribution of Php5 this results in an (unresolved) error, but with an Apache2/Php5 build from source, the example is fine. Thanks to all, for responses. Cheers, Andrew. __ NOD32 1.1380 (20060125) Information __ This message was checked by NOD32 antivirus system. http://www.eset.com -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DEV] PHP / C++ Interaction
On 2/13/06, Andrew Mather [EMAIL PROTECTED] wrote: - can I talk to a C++ library from PHP, either directly or via a PHP/C extension? You could just have the PHP extension written in C++. There is no requirement of PHP extensions to be written in C, you just need to make sure you properly wrap the C parts inherited from the core w/ an extern C block. I have wrapped more than a handful of C++ libraries at my day job in into PHP extensions using more or less the following approach. Here's a rough overview of the changes needed (this list might not be complete, but should be close). config.m4 changes - I set the the compiler environment variables (aka CC and CXX) to both use g++. Not sure if this is necessary. In your included libraries (aka PHP_ADD_LIBRARY_WITH_PATH) make sure you include libstdc++ your source file changes --- Wrap the following in an extern C like shown below: extern C { #ifdef HAVE_CONFIG_H #include config.h #endif #include php.h #include php_ini.h #include ext/standard/info.h #include php_your_extension_name.h } And later on further down wrap the following: extern C { #ifdef COMPILE_DL_YOUR_EXTENSION_NAME ZEND_GET_MODULE(your_extension_name) #endif } As best as I can remember, that is all that is necessary to write a C++ PHP Extension instead of a C one. Brighter minds on this list might know better if I am forgetting something, but I remember it being very minimal changes so I think the above is it. -Jeremy -- --- Jeremy Johnstone http://www.jeremyjohnstone.com [EMAIL PROTECTED]
Re: [PHP-DEV] PHP / C++ Interaction
Just search the archives, or the zend weeklies index page (http://www.zend.com/zend/week/) if you're short of time. I remember linking to someone's material regarding C++ extensions for PHP a few months back, and it'll be in the 'item descriptions' there. - Steph - Original Message - From: Jeremy Johnstone [EMAIL PROTECTED] To: Andrew Mather [EMAIL PROTECTED] Cc: internals@lists.php.net Sent: Monday, February 20, 2006 3:08 AM Subject: Re: [PHP-DEV] PHP / C++ Interaction On 2/13/06, Andrew Mather [EMAIL PROTECTED] wrote: - can I talk to a C++ library from PHP, either directly or via a PHP/C extension? You could just have the PHP extension written in C++. There is no requirement of PHP extensions to be written in C, you just need to make sure you properly wrap the C parts inherited from the core w/ an extern C block. I have wrapped more than a handful of C++ libraries at my day job in into PHP extensions using more or less the following approach. Here's a rough overview of the changes needed (this list might not be complete, but should be close). config.m4 changes - I set the the compiler environment variables (aka CC and CXX) to both use g++. Not sure if this is necessary. In your included libraries (aka PHP_ADD_LIBRARY_WITH_PATH) make sure you include libstdc++ your source file changes --- Wrap the following in an extern C like shown below: extern C { #ifdef HAVE_CONFIG_H #include config.h #endif #include php.h #include php_ini.h #include ext/standard/info.h #include php_your_extension_name.h } And later on further down wrap the following: extern C { #ifdef COMPILE_DL_YOUR_EXTENSION_NAME ZEND_GET_MODULE(your_extension_name) #endif } As best as I can remember, that is all that is necessary to write a C++ PHP Extension instead of a C one. Brighter minds on this list might know better if I am forgetting something, but I remember it being very minimal changes so I think the above is it. -Jeremy -- --- Jeremy Johnstone http://www.jeremyjohnstone.com [EMAIL PROTECTED] -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DEV] PHP / C++ Interaction
Having got a PHP/C extension .so shared library working, (courtesy this mailing list), and now also ported a C++ data server to Linux, which could also be a (C++) .so, the obvious question is: - can I talk to a C++ library from PHP, either directly or via a PHP/C extension? - aka: is there a 'com'/.Net equivalent on Linux to permit language independent calls ? Trivially possible, trivially impossible, or somewhere in-between? Cheers, Andrew.
Re: [PHP-DEV] PHP / C++ Interaction
Andrew Mather schrieb: is there a 'com'/.Net equivalent on Linux to permit language independent calls? http://pecl.php.net/package/ffi might be what you're looking for. -- Sebastian Bergmann http://www.sebastian-bergmann.de/ GnuPG Key: 0xB85B5D69 / 27A7 2B14 09E4 98CD 6277 0E5B 6867 C514 B85B 5D69 -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php