How to use swig to generate php interface for C ++, therefore

I tried a hundred things and I can not get my .so file for interacting with php using swig. I can generate the files, then I had to compile Zend and the link with it to make .so, but now it keeps crashing when loading.

Can someone skip me, but how to use swig to create a PHP interface for the C ++ library? The documentation on the swig website does not help.

+6
c ++ php swig
source share
3 answers

This example seems to be informative. Have you tried this?

+1
source share

I was stuck in the same situation, but then Guy's answer explained that the example.i file had to be created first, and not just a fancy parameter, to tell swig the name of your project. Paragraph 2.3.1 of this manual ! says this example.i file is about.

/* File : example.i */ %module example %{ /* Put headers and other declarations here */ extern double My_variable; extern int fact(int); extern int my_mod(int n, int m); %} extern double My_variable; extern int fact(int); extern int my_mod(int n, int m); 
+1
source share

Hey. Double check the permissions of the folder where your PHP code is located. I faced the same problem. In fact, I made some files for reading and writing in the same directory, and I had to set the resolution for my php project accordingly, otherwise it said No data was received , and when I see apache log in error I see a segmentation error.

So please check. this can help.

And yes, the documentation on the Swig site is still not very useful for PHP developers.

0
source share

All Articles