Re: [PHP-DEV] Extensions calling C++ From: Andi Gutmans (andi <email protected>)
Date: 07/09/00

Hi,

I don't think PHP's build system works with C++ right now. I don't think it
looks for a C++ compiler neither do I think that it supports .C or .cpp
extensions.
I'm sure Sascha who is currently the main build-meister can expand more on
this issue.
Anyway, we purposely put a bunch of extern "C"'s in Zend and if there are
any places you need which are missing such a decleration (I know there are
places which we missed) then we can add them. Just let us know.

Andi

At 01:20 PM 7/9/00 -0600, John Keiser wrote:
>Hello all,
>
>I am trying to make an extension that uses a library written in C++.
>
>I have gotten a simple extension working with C (ext_skel and the build
>process are really something else, good job!), and my current approach is to
>make the .c call a .cpp or .C file which has extern "C" functions in it
>calling the C++ lib functions. To this end, I am currently just trying to
>get a .c and .C/cpp file to compile together in the extension.
>
>The problem is, the .C or .cpp file does not seem to get compiled at all;
>instead it is passed direct on the libtool line.
>
>Is there a better way to do this? My next option is to move the .C file in
>question into an external library and compile separately, but it'd be easier
>to have the file in the PHP lib where it belongs.
>
>
>
>This is what my project looks like (originally generated with ext_skel),
>with just pertinent info:
>
>Makefile.in:
>------------------
>LTLIBRARY_NAME = libsword.la
>LTLIBRARY_SOURCES = sword.c sword_int.C
>LTLIBRARY_SHARED_NAME = sword.la
>include $(top_srcdir)/build/dynlib.mk
>------------------
>
>sword.c: generated by ext_skel, only added #include "sword_inc.h" and have
>it call browse_int().
>
>sword_inc.h:
>------------------
>BEGIN_EXTERN_C()
>char * browse_int(char * verse);
>END_EXTERN_C()
>------------------
>
>sword_inc.C:
>------------------
>#include "php.h"
>#include "sword_int.h"
>
>BEGIN_EXTERN_C();
>char * browse_int(char * verse) {
> char * retval = emalloc(strlen(verse) + 9);
> sprintf(retval, "<B>%s:</B>", verse);
> return retval;
>}
>END_EXTERN_C();
>------------------
>
>I have tried sword_inc.C with and without the EXTERN_C, but since it isn't
>compiling, I'm guessing the point is moot right now :)
>
>
>It seems like Zend was planning to add C++ support somehow, since the
>BEGIN_EXTERN_C macro is defined.
>
>Any help would be appreciated.
>
>--John Keiser
>
>
>--
>PHP Development Mailing List <http://www.php.net/>
>To unsubscribe, e-mail: php-dev-unsubscribe <email protected>
>For additional commands, e-mail: php-dev-help <email protected>
>To contact the list administrators, e-mail: php-list-admin <email protected>

---
Andi Gutmans <andi <email protected>>
http://www.zend.com/

-- PHP Development Mailing List <http://www.php.net/> To unsubscribe, e-mail: php-dev-unsubscribe <email protected> For additional commands, e-mail: php-dev-help <email protected> To contact the list administrators, e-mail: php-list-admin <email protected>