Reputation: 5239
I am new to coding PHP extensions. And i was tryin the following snippet in a .cpp file
#include <iostream>
#include "Zend/zend.h"
using namespace std;
void describe_zval(zval *foo)
{
if (foo->type == IS_NULL)
{
php_printf("The variable is NULL");
}
else
{
php_printf("The variable is of type %d", foo->type);
}
}
int main(void)
{
return 0;
}
The variable zval
(which is a struct )is present in /usr/local/src/php-5.4.11/Zend/zend.h
Compilation
g++ -I /usr/local/src/php-5.4.11 -I /usr/local/src/php-5.4.11/Zend try.cpp
This gives the error
In file included from /usr/local/src/php-5.4.11/Zend/zend_alloc.h:27:0,
from /usr/local/src/php-5.4.11/Zend/zend.h:237,
from try.c:2:
/usr/local/src/php-5.4.11/Zend/../TSRM/TSRM.h:20:26: fatal error: tsrm_config.h: No such file or directory
compilation terminated.
tsrm_config.h is present in /usr/local/src/php-5.4.11/
How do i include the subdirectories under /usr/local/src/php-5.4.11/
since the compilation process requires many files located in several subdirectories of /usr/local/src/php-5.4.11/
Upvotes: 0
Views: 1475
Reputation: 2145
In the php-5.4.11 directory, you should also include Zend, main, TSRM (if you want to develop your extension on a thread-safe server). I mean you should have:-I /usr/local/src/php-5.4.11/main
I /usr/local/src/php-5.4.11/Zend
I /usr/local/src/php-5.4.11/TSRM
, you can create a makefile for including these directories. By the way, why don't you use SWIG for creating your wrapper code? you should try that.
Upvotes: 1