Re: Extensions calling C++
| From: | Sascha Schumann | Date: | Thu, 01 Jan 1970 00:00:00 +0000 |
| Subject: | Re: Extensions calling C++ | ||
| References: | 1 | Groups: | php.dev |
| Request: | Send a blank email to php-dev+get-23954@lists.php.net to get a copy of this message | ||
On Sun, 9 Jul 2000, 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
Please update your CVS checkout and rewrite the above line as
LTLIBRARY_SOURCES = sword.c
LTLIBRARY_OBJECTS_X = sword_int.lo
Then rename sword_int.C to sword_int.cxx.
Also add PHP_REQUIRE_CXX to your config.m4 (this shall be run
conditionally only).
Please let us know whether it works.
> It seems like Zend was planning to add C++ support somehow, since the
> BEGIN_EXTERN_C macro is defined.
Some parts of Zend use C++. But I dislike the () behind the *_EXTERN_C
macros which are otherwise quite convenient.