On 2008-05-30, Shishir Malani <
ssmalani@...> wrote:
> Now, I have created the following files,
If sending example files, it's better to send them as mime attachments
so they can easily be saved and tried. I'm afraid I haven't tested your
example because I don't have the patience to cut and paste the text from
the message to recreate the various files, and have to fix up any word
wrap damage and other mailer mangling.
It would also be helpful to tell us what versions of PHP and SWIG you
are using. I'm guessing some version of PHP5 since you use "-php5"
below.
> After this, I run the following commands and everything compiles
> without any problems,
>
> swig -c++ -php5 example1.i
> g++ -c example1.cpp example1_wrap.cpp `php-config --includes` -fPIC
> c++ -shared example1.o example1_wrap.o -o example1.so
I don't think this is causing you problems, but it would be better to
compile and link with either g++ *OR* c++ (i.e. use the same one in
both cases).
> I then place the generated example1.so file in the extension directory
> of php using
>
> mv example.so `php-config --extension-dir`
Do you mean "example1.so" here? That's what you compiled above and try
to load below.
> And also place it in the apache www root along with the php test script.
>
> The php test script is defined below,
>
><?php
>
> echo dl('example1.so');
>
> $v = new Example1();
>
> $v->get_val(1,2,3);
>
> echo $v->sum();
>
> ?>
(As you seem to have realised from your follow-up email) you need the
PHP wrapper to be included:
include 'example1.php';
This will dl the shared object for you if it isn't already loaded, so
you don't need to do that yourself.
> Fatal error: Class 'Example1' not found in /var/www/test.php on line 3
> php.ini file has dynamic loading enabled because I ran everything with
> a simple C file and it worked perfectly. I get the same error as above
> when I try using structures as well.
Sounds like php failed to load example1.so.
Try this from CLI php:
php5 -r 'include "example1.php"; $v = new Example1();'
If that works, then it's some difference in the apache environment.
Look in apache's error_log for clues. A random guess - perhaps your
umask is very restrictive, so example1.so isn't readable by the web
server user.
Cheers,
Olly
-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php_______________________________________________
Swig-user mailing list
Swig-user@...
https://lists.sourceforge.net/lists/listinfo/swig-user