To call a C/C++ function in PHP using SWIG.

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • piyushtiwari
    New Member
    • Jun 2007
    • 1

    To call a C/C++ function in PHP using SWIG.

    I have to call a C++ function in php. I tried it using swig. I wrote the interface file example.i to call the functions from example.cxx in php. To build a PHP extension, I run swig using the -php option as follows:

    ~$ swig -php example.i

    This produced 3 files example_wrap.c, php_example.h and example.php.
    Now to build the extension as a dynamically loaded module I used

    cc -I.. $(PHPINC) -fpic -c example_wrap.c

    It is showing errors like
    example_wrap.c: 689:18: zend.h: No such file or directory
    example_wrap.c: 690:22: zend_API.h: No such file or directory
    example_wrap.c: 691:17: php.h: No such file or directory

    For compiling I have used........

    cc -I /usr/local/include/php/ -fpic -c example_wrap.c

    Please suggest me what to do to make it work???
  • pbmods
    Recognized Expert Expert
    • Apr 2007
    • 5821

    #2
    Heya, piyushtiwari. Welcome to TSDN!

    You posted this in the PHP Articles section (despite the HUMONGOUS SIGN that said, "DO NOT POST QUESTIONS HERE!").

    I'll go ahead and move it to the PHP FORUM so that you might actually get some responses :)

    Comment

    • Motoma
      Recognized Expert Specialist
      • Jan 2007
      • 3236

      #3
      I have not used swig, therefore this is only a guess.
      Perhaps you need to have the PHP source installed on your machine in order to compile extensions for it.

      Comment

      Working...