[PHP] Load a C library into extension?
Hi all, I have no doubt posted many queries here in the past few days, and am thankful for all the help I have received. :) I have been able to write a helloworld extension and compile it. The next step is to call a function in a library libfoo.so. I think this needs a modification in config.m4. Any ideas how to go about it? I have already tried editing LIBNAME and LIBSYMBOL. It says: checking for foo in -lfoo... no configure: error: wrong foo lib version or lib not found The file is present as ext/myext/lib/libfoo.so. Thanks again, Deepak -- N Deepak || http://www.ndeepak.info/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Capturing user's IP Address
Jacques wrote: Which function can I use to capture a user's IP Address when he registers on my site. I would like to store this value in a database. print $_SERVER['REMOTE_ADDR']; --Deepak -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Cookies
William Stokes wrote: Hello, If I send a session cookie to browser where it is stored in WinXP? Or is it stored as a separate file at all. I know that the script sends the cookie but I can't find it in the client computer harddrive. I am testing with Opera, IE6 and Firefox. This is not dependent on the OS, but the browser. IE stores in %WINDIR%\Cookies. Netscape stores in a Cookies subdirectory under C:\Program Files\Netscape\User\... --Deepak -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Can't load extension (was Re: PHP to C interface?)
N Deepak wrote: On Mon, Feb 21, 2005 at 02:08:28PM -0800, Richard Lynch wrote: You have to make install your new .so file to get copied over into your PHP extensions directory, which from the messages seems to be /usr/local/lib/php/extensions/no-debug-non-zts-20020429/ on your system... I'm betting you have an 'ext/foo.so' file, but it's not installed yet. No, there's none! [EMAIL PROTECTED] ext]$ pwd /home/deep/php-4.3.10/ext [EMAIL PROTECTED] ext]$ find . -name *.so [EMAIL PROTECTED] ext]$ I gave this find after saying './buildconf --force', './configure --with-nscli', 'make'. (Which is what the ext_skel script asked me to do, after editing config.m4) I found the problem. One has to run 'phpize' in the extension directory, and then configure/make/make install. ext_skel doesn't mention it at all, though? Thanks, Deepak To get this error: [EMAIL PROTECTED] php-4.3.10]$ ./sapi/cli/php -f ext/foo/nscli.php Warning: dl(): Unable to load dynamic library '/usr/local/lib/php/extensions/no-debug-non-zts-20020429/foo.so' - /usr/local/lib/php/extensions/no-debug-non-zts-20020429/foo.so: cannot open shared object file: No such file or directory in /home/deep/php-4.3.10/ext/foo/nscli.php on line 3 Functions available in the test extension:br Warning: Invalid argument supplied for foreach() in /home/deep/php-4.3.10/ext/foo/nscli.php on line 8 br Module foo is not compiled into PHP [EMAIL PROTECTED] php-4.3.10]$ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] zend_parse_parameters seg faults on string input.
Hi all, In the PHP file, I have written: helloworld(hello, world) where helloworld is in an extension. Now, I use zend_parse_parameters() to parse input as follows: char* hstr = NULL, *wstr = NULL; argc = ZEND_NUM_ARGS(); if (zend_parse_parameters(argc TSRMLS_CC, ss, hstr, wstr) == FAILURE) return; I get a seg-fault when I run the PHP file. However, it works for one argument. Am I missing something? Thanks, Deepak -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP to C interface?
On Fri, Feb 18, 2005 at 09:20:02AM -0800, Richard Lynch wrote: Is there a way to invoke C functions in a library (.so) from PHP? Like Xs in Perl? By definition, then, all you have to do is learn how to write a PHP extension, which Rasmus tells you how to do in a one-hour lecture at any PHP/Linux/Apache/OpenSource conference you care to name :-) But rather than spend hundreds to attend a conference, you can access his talk on this topic at: http://talks.php.net Thanks for pointing out. When I look up the 'Extensions' category, I get mostly presentations on HTML Tidy under PHP? http://talks.php.net/index.php/Extensions?PHPSESSID=b8b25bec4cebea1f748893292ab077e5 Thanks, Deepak -- N Deepak || http://www.ndeepak.info/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Unable to load extension (was Re: PHP to C interface?)
On Fri, Feb 18, 2005 at 09:20:02AM -0800, Richard Lynch wrote: N Deepak wrote: Is there a way to invoke C functions in a library (.so) from PHP? Like Xs in Perl? By definition, then, all you have to do is learn how to write a PHP extension, which Rasmus tells you how to do in a one-hour lecture at any PHP/Linux/Apache/OpenSource conference you care to name :-) I downloaded php-4.3.10 off http://www.php.net/ and am trying to build a simple helloworld extension. I ran ext_skel, modified config.m4 where it had the PHP_ARG_ENABLE line: PHP_ARG_ENABLE(foo, whether to enable foo support, dnl Make sure that the comment is aligned: [ --enable-foo Enable foo support]) I followed the remaining steps too, (./buildconf --force, ./configure --with-foo, make) Now when I say ./sapi/cli/php -f ext/foo/foo.php I get this error: Warning: dl(): Unable to load dynamic library '/usr/local/lib/php/extensions/no-debug-non-zts-20020429/foo.so' - /usr/local/lib/php/extensions/no-debug-non-zts-20020429/foo.so: cannot open shared object file: No such file or directory in /home/deep/php-4.3.10/ext/foo/foo.php on line 3 Functions available in the test extension:br Warning: Invalid argument supplied for foreach() in /home/deep/php-4.3.10/ext/foo/foo.php on line 8 br Module foo is not compiled into PHP [EMAIL PROTECTED] php-4.3.10]$ I tried in vain to look up the Web for solutions, but to no avail. Could anyone help me please? Thanks, Deepak -- N Deepak || http://www.ndeepak.info/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Can't load extension (was Re: PHP to C interface?)
On Fri, Feb 18, 2005 at 09:20:02AM -0800, Richard Lynch wrote: N Deepak wrote: Is there a way to invoke C functions in a library (.so) from PHP? Like Xs in Perl? By definition, then, all you have to do is learn how to write a PHP extension, which Rasmus tells you how to do in a one-hour lecture at any PHP/Linux/Apache/OpenSource conference you care to name :-) I downloaded php-4.3.10 and tried to create a simple extension. I followed instructions exactly as ext_skel told. I modified config.m4 only in the PHP_ARG_ENABLE() lines. I ran buildconf, configure --with-foo, make and then ./sapi/cli/php -f ext/foo/foo.php. To get this error: [EMAIL PROTECTED] php-4.3.10]$ ./sapi/cli/php -f ext/foo/nscli.php Warning: dl(): Unable to load dynamic library '/usr/local/lib/php/extensions/no-debug-non-zts-20020429/foo.so' - /usr/local/lib/php/extensions/no-debug-non-zts-20020429/foo.so: cannot open shared object file: No such file or directory in /home/deep/php-4.3.10/ext/foo/nscli.php on line 3 Functions available in the test extension:br Warning: Invalid argument supplied for foreach() in /home/deep/php-4.3.10/ext/foo/nscli.php on line 8 br Module foo is not compiled into PHP [EMAIL PROTECTED] php-4.3.10]$ Could someone please help me? Many thanks in advance, Deepak -- N Deepak || http://www.ndeepak.info/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Can't load extension (was Re: PHP to C interface?)
On Mon, Feb 21, 2005 at 02:08:28PM -0800, Richard Lynch wrote: I downloaded php-4.3.10 and tried to create a simple extension. I followed instructions exactly as ext_skel told. I modified config.m4 only in the PHP_ARG_ENABLE() lines. I ran buildconf, configure --with-foo, make and then ./sapi/cli/php -f ext/foo/foo.php. What happened to make install ??? You have to make install your new .so file to get copied over into your PHP extensions directory, which from the messages seems to be /usr/local/lib/php/extensions/no-debug-non-zts-20020429/ on your system... I'm betting you have an 'ext/foo.so' file, but it's not installed yet. No, there's none! [EMAIL PROTECTED] ext]$ pwd /home/deep/php-4.3.10/ext [EMAIL PROTECTED] ext]$ find . -name *.so [EMAIL PROTECTED] ext]$ I gave this find after saying './buildconf --force', './configure --with-nscli', 'make'. (Which is what the ext_skel script asked me to do, after editing config.m4) Thanks for all the help, I think I'm still not done, however. Regards, Deepak To get this error: [EMAIL PROTECTED] php-4.3.10]$ ./sapi/cli/php -f ext/foo/nscli.php Warning: dl(): Unable to load dynamic library '/usr/local/lib/php/extensions/no-debug-non-zts-20020429/foo.so' - /usr/local/lib/php/extensions/no-debug-non-zts-20020429/foo.so: cannot open shared object file: No such file or directory in /home/deep/php-4.3.10/ext/foo/nscli.php on line 3 Functions available in the test extension:br Warning: Invalid argument supplied for foreach() in /home/deep/php-4.3.10/ext/foo/nscli.php on line 8 br Module foo is not compiled into PHP [EMAIL PROTECTED] php-4.3.10]$ -- N Deepak || http://www.ndeepak.info/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Unable to load extension (was Re: PHP to C interface?)
Jason Barnett wrote: Now when I say ../sapi/cli/php -f ext/foo/foo.php I get this error: Warning: dl(): Unable to load dynamic library Were you actually trying to dl() the library in your PHP code? If you compiled the extension into PHP this shouldn't be necessary. In fact, unless you build an extension to be a DSO you shouldn't be able to use dl() with that extension anyways! This is actually my first venture to PHP extensions. I am trying to write a simple C function, which prints 'hello world', as a PHP extension. I defined a helloworld.proto as: int helloworld() prints hello, world executed ext_skel, and followed the remaining steps that it showed on-screen, including editing config.m4. '/usr/local/lib/php/extensions/no-debug-non-zts-20020429/foo.so' - /usr/local/lib/php/extensions/no-debug-non-zts-20020429/foo.so: cannot open shared object file: No such file or directory in /home/deep/php-4.3.10/ext/foo/foo.php on line 3 Functions available in the test extension:br Warning: Invalid argument supplied for foreach() in /home/deep/php-4.3.10/ext/foo/foo.php on line 8 br Module foo is not compiled into PHP [EMAIL PROTECTED] php-4.3.10]$ I'm sorry my previous mail appeared twice - I was confused by a majordomo reply saying 'Commands not understood'. Thanks, Deepak -- N Deepak || http://www.ndeepak.info/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] PHP to C interface?
Hi, Is there a way to invoke C functions in a library (.so) from PHP? Like Xs in Perl? Thanks, Deepak -- N Deepak || http://www.ndeepak.info/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP to C interface?
On Fri, Feb 18, 2005 at 02:56:05PM +0530, Zareef Ahmed wrote: Hi, Please Visit http://pear.php.net/package/Inline_C Thanks very much. Have you tried using it? How mature is it? I found no documentation or installation guide. Best regards, Deepak On Fri, 18 Feb 2005 01:19:19 -0800, N Deepak [EMAIL PROTECTED] wrote: Hi, Is there a way to invoke C functions in a library (.so) from PHP? Like Xs in Perl? Thanks, Deepak -- N Deepak || http://www.ndeepak.info/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php