Since the php.net mailing lists and news server are all down, I figured I might as well try posting this here in the hopes that someone here is a PHP developer and can give me a hand.
I'm in the process of creating a PHP extension that will give PHP an implementation of the Porter suffix stemming algorithm. Everything is done except for one thing -- building PHP with the extension. I've been having problems getting the extension to compile properly when it comes time to compile PHP as an Apache module.
Here's the deal:
I wrote the extension in C++, not C. When it comes time to compile Apache, I get the following errors before the make process bails:
-- snip, snip, snip, on to the important stuff --
modules/php4/libphp4.a(internal_functions.o): In function php_startup_internal_extensions':
/root/setup/php/php-4.0.5/main/internal_functions.c:60: undefined reference toporter_module_entry'
collect2: ld returned 1 exit status
make[2]: [target_static] Error 1
make[2]: Leaving directory /root/setup/apache/apache_1.3.20/src'
make[1]: *** [build-std] Error 2
make[1]: Leaving directory/root/setup/apache/apache_1.3.20'
make: [build] Error 2
I've seen this error plenty in the mailing lists and such, but damned if I can get around it.
The problem seems to be stemming from the mix of PHP's C code base and my C++ (obviously). I've extern'ed the hell out of my extension, using extern "C" for everything I can think of. In the header file for the extension (php_porter.h), I've extern'ed the zend_module_entry lines as such:
#ifdef __cplusplus
extern "C" zend_module_entry porter_module_entry;
#endif
The problem persists.
It's been a year or two since I've touched C++ (or C for that matter), so maybe I'm missing something obvious.
Anybody with a solution or advice?
As a side note, I can't even get a vanilla, empty C++ extension to compile during the Apache build -- i.e. if I use ext_skel to make the necessary templates and rename the .c file it creates to .cpp and make the necessary changes to the Makefile and php_*.h header and such, it still doesn't work. My own code is fine and it works nicely -- I just want it to work with PHP. (And if it works, donate it to the PHP project -- I'm sure I'm not the only one who could use a suffix stripper in PHP search engines.)
Thanks for any help.
J