473,320 Members | 1,820 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

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???
Jun 15 '07 #1
2 3551
pbmods
5,821 Expert 4TB
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 :)
Jun 15 '07 #2
Motoma
3,237 Expert 2GB
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.
Jun 15 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

7
by: Carl Waldbieser | last post by:
I tried to adapt the instructions for building the M2Crypto module (http://sandbox.rulemaker.net/ngps/m2/INSTALL.html) to build a version compatible with Python2.3, but I've had some mixed results....
0
by: Jon Moldover | last post by:
Hi, I'm using Python in my win32 app by linking to the python23.dll. I'm trying to expose some c++ code in my app to Python so I can make application calls from Python scripts (according to the...
1
by: Paul | last post by:
following hangs when re-entered run() { PyEval_RestoreThread(context); pName = PyString_FromString(script); Py_DECREF(pName);
0
by: Bill Davy | last post by:
I am working with MSVC6 on Windows XP. I have created an MSVC project called SHIP I have a file SHIP.i with "%module SHIP" as the first line (file is below). I run SHIP.i through SWIG 1.3.24...
11
by: Java and Swing | last post by:
Is there some other way, besides SWIG, which will allow me to call functions inside an Ansi C DLL? Example (C): defs.h ------- typedef unsigned long MY_DIGIT; myapp.c
7
by: Pankaj | last post by:
The module which i am creating is like Part A: 1. It does some processing by using python code. 2. The result of this python code execution is written to a text file. ] Part B: 1. I read a...
0
by: Basha J P M | last post by:
I am beginner in python. I am working through the tutorial examples from http://www.swig.org/ and have run into some problems. I took the following command instructions from the tutorial on...
5
by: Charlie | last post by:
Hi All, I am new to using swig/C++/python. I got some problem with function pointers. I posted in swig-user, but got no response. So I forwarded it here. You help is greatly appreciated. ...
0
by: datapata | last post by:
Hi I have some C++ code that I need to access from Python. I don't need to access any classes or anything, just a couple of functions that take one array as input and produce another array as...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.