Hi Brian, I followed your suggestion but I still got the same error message: ext/hello/.libs/hello.o: In function `zif_confirm_hello_compiled':/home/www/php-5.3.1/ext/hello/hello.c:168: undefined reference to `ap_rprintf'collect2: ld returned 1 exit statusmake: *** [sapi/cli/php] Error 1 Thanks for further help,Rwe --- On Sun, 1/17/10, Brian J. France <br...@brianfrance.com> wrote:
From: Brian J. France <br...@brianfrance.com> Subject: Re: [PHP-DEV] Can we call Apache 2 API function from a PHP 5 extension module? To: "rwe rt" <rwe...@yahoo.com> Cc: internals@lists.php.net Received: Sunday, January 17, 2010, 1:05 AM Try this instead: request_rec *r = (request_rec *)(((SG(server_context) == NULL) ? NULL : ((php_struct*)SG(server_context))->r)); Apache 2.x server_context is not a request_rec, it is a struct with a request rec in it. Brian On Jan 16, 2010, at 7:25 PM, rwe rt wrote: > Hi all,I compiled php-5.3.1 with apache 2.2.14 as DSO and wanted to test how > to call Apache API from a PHP module:Run ./ext_skel --extname=helloModified > ext/hello.c and the function PHP_FUNCTION(confirm_hello_compiled) so that it > contains > > #include "SAPI.h" > #include "httpd.h" > #include "http_config.h" > #include "http_protocol.h" > #include "ap_config.h" > request_rec *hello_r;PHP_FUNCTION(confirm_hello_compiled) { hello_r = > (request_rec *)SG(server_context); ap_rprintf(hello_r, "Hello world\n"); > return SUCCESS; > }Under php root, run ./buildconf and ./configure > --with-apxs=/home/www/bin/apxs --enable-helloIt worked fine. But when I > furhter ran: > > makeI got an error like:....ext/hello/.libs/hello.o: In function > zif_confirm_hello_compiled': /home/www/php-5.3.1/ext/hello/hello.c:167: > undefined reference toap_rprintf'near the end of compiling.As far as I know, > PHP 5 can only be compiled as DSO and don't have access to compiled objects > in Apache 2 directly. How to modify config.m4 or other files so that I can > make compiling successful? Any help would be greatly appreciated!Rwe > > > __________________________________________________________________ > Be smarter than spam. See how smart SpamGuard is at giving junk email the > boot with the All-new Yahoo! Mail. Click on Options in Mail and switch to > New Mail today or register for free at http://mail.yahoo.ca __________________________________________________________________ Get a sneak peak at messages with a handy reading pane with All new Yahoo! Mail: http://ca.promos.yahoo.com/newmail/overview2/