I'm getting this php.h no such file or directory error
Change to the directory php/ext.
Open the file Makefile in an editor, such as vi, and change the value of PHP_INCROOT, if necessary. <--- what value? I use Centos 7
gcc -O2 -fpic -DHAVE_ODBTP -DCOMPILE_DL_ODBTP -I/usr/local/php/include/php -I/usr/local/php/include/php/main -I/usr/local/php/include/php/TSRM -I/usr/local/php/include/php/Zend -I../.. -I./odbtp -o php_odbtp.o -c odbtp/php_odbtp.c
odbtp/php_odbtp.c:29:17: fatal error: php.h: No such file or directory
#include "php.h"
^
compilation terminated.
make: *** [php_odbtp.o] Error 1
Fixed. Installed Zend Framework, php_devel
Related
I'm trying to install intl on Mac os Ventura 13.0.1 with XAMPP 8.1.12 with pecl with this command:
sudo /Applications/XAMPP/xamppfiles/bin/pecl install intl
i cannot use directly pecl because i've also other installed php version.
Obviously i've already installed icu4c with command:
brew install icu4c
Here's result of brew list icu4c
/opt/homebrew/Cellar/icu4c/71.1/bin/derb
/opt/homebrew/Cellar/icu4c/71.1/bin/genbrk
/opt/homebrew/Cellar/icu4c/71.1/bin/gencfu
/opt/homebrew/Cellar/icu4c/71.1/bin/gencnval
/opt/homebrew/Cellar/icu4c/71.1/bin/gendict
/opt/homebrew/Cellar/icu4c/71.1/bin/genrb
/opt/homebrew/Cellar/icu4c/71.1/bin/icu-config
/opt/homebrew/Cellar/icu4c/71.1/bin/icuexportdata
/opt/homebrew/Cellar/icu4c/71.1/bin/icuinfo
/opt/homebrew/Cellar/icu4c/71.1/bin/makeconv
/opt/homebrew/Cellar/icu4c/71.1/bin/pkgdata
/opt/homebrew/Cellar/icu4c/71.1/bin/uconv
/opt/homebrew/Cellar/icu4c/71.1/include/unicode/ (189 files)
/opt/homebrew/Cellar/icu4c/71.1/lib/libicudata.71.1.dylib
/opt/homebrew/Cellar/icu4c/71.1/lib/libicui18n.71.1.dylib
/opt/homebrew/Cellar/icu4c/71.1/lib/libicuio.71.1.dylib
/opt/homebrew/Cellar/icu4c/71.1/lib/libicutest.71.1.dylib
/opt/homebrew/Cellar/icu4c/71.1/lib/libicutu.71.1.dylib
/opt/homebrew/Cellar/icu4c/71.1/lib/libicuuc.71.1.dylib
/opt/homebrew/Cellar/icu4c/71.1/lib/icu/ (4 files)
/opt/homebrew/Cellar/icu4c/71.1/lib/pkgconfig/ (3 files)
/opt/homebrew/Cellar/icu4c/71.1/lib/ (18 other files)
/opt/homebrew/Cellar/icu4c/71.1/sbin/escapesrc
/opt/homebrew/Cellar/icu4c/71.1/sbin/genccode
/opt/homebrew/Cellar/icu4c/71.1/sbin/gencmn
/opt/homebrew/Cellar/icu4c/71.1/sbin/gennorm2
/opt/homebrew/Cellar/icu4c/71.1/sbin/gensprep
/opt/homebrew/Cellar/icu4c/71.1/sbin/icupkg
/opt/homebrew/Cellar/icu4c/71.1/share/icu/ (4 files)
/opt/homebrew/Cellar/icu4c/71.1/share/man/ (15 files)
Now once i try to install intl with pecl i got this error:
cc -I. -I/private/var/tmp/pear/temp/intl -I/private/var/tmp/pear/temp/pear-build-rootQBIGcB/intl-3.0.0/include -I/private/var/tmp/pear/temp/pear-build-rootQBIGcB/intl-3.0.0/main -I/private/var/tmp/pear/temp/intl -I/Applications/XAMPP/xamppfiles/include/php -I/Applications/XAMPP/xamppfiles/include/php/main -I/Applications/XAMPP/xamppfiles/include/php/TSRM -I/Applications/XAMPP/xamppfiles/include/php/Zend -I/Applications/XAMPP/xamppfiles/include/php/ext -I/Applications/XAMPP/xamppfiles/include/php/ext/date/lib -I/include -DHAVE_CONFIG_H -g -O2 -Wno-write-strings -DZEND_COMPILE_DL_EXT=1 -c /private/var/tmp/pear/temp/intl/php_intl.c -MMD -MF php_intl.dep -MT php_intl.lo -fno-common -DPIC -o .libs/php_intl.o
In file included from /private/var/tmp/pear/temp/intl/php_intl.c:25:
In file included from /private/var/tmp/pear/temp/intl/php_intl.h:32:
/private/var/tmp/pear/temp/intl/collator/collator_sort.h:23:76: error: expected ')'
typedef int (*collator_compare_func_t)( zval *result, zval *op1, zval *op2 TSRMLS_DC );
^
/private/var/tmp/pear/temp/intl/collator/collator_sort.h:23:39: note: to match this '('
typedef int (*collator_compare_func_t)( zval *result, zval *op1, zval *op2 TSRMLS_DC );
^
In file included from /private/var/tmp/pear/temp/intl/php_intl.c:25:
/private/var/tmp/pear/temp/intl/php_intl.h:33:10: fatal error: 'unicode/ubrk.h' file not found
#include <unicode/ubrk.h>
^~~~~~~~~~~~~~~~
2 errors generated.
make: *** [php_intl.lo] Error 1
ERROR: `make' failed
Once i start the install intl the script ask me:
Specify where ICU libraries and headers can be found [DEFAULT] :
i simple hint enter and got same error but i've also tried to use:
/opt/homebrew/Cellar/icu4c/71.1/include/unicode/
but same error appear
I'm loosing my mind with this problem!!
Anyone tried installing "
RarArchive
on their macbookpro? I tried installing but I got this error
.1.13/include/php/ext/date/lib -DHAVE_CONFIG_H -g -O2 -DRARDLL -DSILENT -Wno-write-strings -Wall -fvisibility=hidden -I/private/tmp/pear/temp/rar/unrar -DZEND_COMPILE_DL_EXT=1 -c /private/tmp/pear/temp/rar/rar_stream.c -MMD -MF rar_stream.dep -MT rar_stream.lo -fno-common -DPIC -o .libs/rar_stream.o
/private/tmp/pear/temp/rar/rar_stream.c:170:23: warning: format specifies type 'unsigned long' but the argument has type 'uint64' (aka 'unsigned long long') [-Wformat]
self->file_size, self->cursor);
^~~~~~~~~~~~
/private/tmp/pear/temp/rar/rar_stream.c:787:58: error: too many arguments to function call, expected 1, have 2
zend_string *arc_str = zend_resolve_path(tmp_archive, tmp_arch_len);
~~~~~~~~~~~~~~~~~ ^~~~~~~~~~~~
1 warning and 1 error generated.
make: *** [rar_stream.lo] Error 1
rolling back 454 file operations
ERROR: `make' failed
Cause I'm trying to solve this warning on my PHP IDE warning.
Thank you!
I tried installing via pecl but it did not work.
I fixed this issue by downgrading the PHP version from 8.1 to 8 and all the error is gone.
Hopefully, this will help others as well.
I'm currently installing PHP with GD library from sources on a RedHat7 server and I'm facing some issues.
I configure PHP with this command:
./configure --with-apxs2=/server/lib/httpd/bin/apxs --with-pdo-mysql --with-config-file-path=/server/php-7.3.9/conf --with-libxml-dir=/server/lib/libxml2 --with-curl=/server/lib/curl --with-gd --enable-mbstring --with-jpeg-dir=/server/lib/libjpeg --with-png-dir=/server/lib/libpng –with-webp-dir=/server/lib/webp
It works but when I'm doing the make command I have this error:
/bin/ld: /server/lib/webp/lib/libwebp.a(picture_enc.o): relocation R_X86_64_PC32 against symbol `WebPMemoryWrite' can not be used when making a shared object; recompile with -fPIC
/bin/ld: final link failed: Bad value
collect2: error: ld returned 1 exit status
make: *** [libphp7.la] Error 1
I also tried to compile and install it without webp (It's not required in the PHP documentation: php doc) but I have this error :
ext/gd/libgd/.libs/gd_webp.o: In function `gdImageCreateFromWebpCtx':
/server/php-7.3.9/ext/gd/libgd/gd_webp.c:68: undefined reference to `WebPGetInfo'
/sever/php-7.3.9/ext/gd/libgd/gd_webp.c:79: undefined reference to `WebPDecodeARGB'
ext/gd/libgd/.libs/gd_webp.o: In function `gdImageWebpCtx':
/server/php-7.3.9/ext/gd/libgd/gd_webp.c:153: undefined reference to `WebPEncodeRGBA'
collect2: error: ld returned 1 exit status
make: *** [sapi/cli/php] Error 1
So it seems to be required.
Can you please help me to solve this
Thanks
I resolved my issue by replacing my installation of webp package.
At first I used the pre-compiled linux package and replacing it by native sources and a compiling, make & make install solve the problem.
Thanks all
Freeswitch 1.5 is successfully installed, Fs_cli is working perfectly.
I am using Centos 6. I want to get ESL to work with PHP. so I have followed the steps written in Freeswitch Wiki for making ESL for PHP. but it is giving error as below :
make MYLIB=".././.libs/libesl.a" SOLINK="-shared -Xlinker -x" CFLAGS="-I/usr/local/src/freeswitch/libs/esl/src/include -I/usr/local/src/freeswitch/src/include -I/usr/local/src/freeswitch/src/include -I/usr/local/src/freeswitch/libs/libteletone/src -fPIC -fvisibility=hidden -DSWITCH_API_VISIBILITY=1 -DHAVE_VISIBILITY=1 -g -ggdb -DHAVE_OPENSSL" CXXFLAGS="-I/usr/local/src/freeswitch/libs/esl/src/include -I/usr/local/src/freeswitch/src/include -I/usr/local/src/freeswitch/src/include -I/usr/local/src/freeswitch/libs/libteletone/src -fPIC -fvisibility=hidden -DSWITCH_API_VISIBILITY=1 -DHAVE_VISIBILITY=1" CXX_CFLAGS="" -C php
make[1]: Entering directory `/usr/local/src/freeswitch/libs/esl/php'
g++ -I/usr/local/src/freeswitch/libs/esl/src/include -I/usr/local/src/freeswitch/src/include -I/usr/local/src/freeswitch/src/include -I/usr/local/src/freeswitch/libs/libteletone/src -fPIC -fvisibility=hidden -DSWITCH_API_VISIBILITY=1 -DHAVE_VISIBILITY=1 -I/usr/local/src/freeswitch/libs/esl/src/include -I/usr/local/src/freeswitch/src/include -I/usr/local/src/freeswitch/src/include -I/usr/local/src/freeswitch/libs/libteletone/src -fPIC -fvisibility=hidden -DSWITCH_API_VISIBILITY=1 -DHAVE_VISIBILITY=1 -Wno-unused-label -Wno-unused-function -c esl_wrap.cpp -o esl_wrap.o
esl_wrap.cpp:741:18: error: zend.h: No such file or directory
esl_wrap.cpp:742:22: error: zend_API.h: No such file or directory
esl_wrap.cpp:743:29: error: zend_exceptions.h: No such file or directory
esl_wrap.cpp:744:17: error: php.h: No such file or directory
esl_wrap.cpp:745:37: error: ext/standard/php_string.h: No such file or directory
esl_wrap.cpp:1093:21: error: php_ini.h: No such file or directory
esl_wrap.cpp:1094:31: error: ext/standard/info.h: No such file or directory
esl_wrap.cpp:803: error: 'E_ERROR' was not declared in this scope
esl_wrap.cpp:824: error: ISO C++ forbids declaration of 'ZEND_RSRC_DTOR_FUNC' with no type
esl_wrap.cpp:824: error: 'SWIG_landfill' was not declared in this scope
esl_wrap.cpp:824: error: expected ',' or ';' before '{' token
esl_wrap.cpp:830: error: variable or field 'SWIG_ZTS_SetPointerZval' declared void
esl_wrap.cpp:830: error: 'zval' was not declared in this scope
esl_wrap.cpp:830: error: 'z' was not declared in this scope
esl_wrap.cpp:830: error: expected primary-expression before 'void'
esl_wrap.cpp:830: error: expected primary-expression before '*' token
esl_wrap.cpp:830: error: 'type' was not declared in this scope
esl_wrap.cpp:830: error: expected primary-expression before 'int'
make[1]: *** [esl_wrap.o] Error 1
make[1]: Leaving directory `/usr/local/src/freeswitch/libs/esl/php'
make: *** [phpmod] Error 2
Re-run ./configure in the top-level freeswitch source directory; that'll pick up the location of the relevant PHP headers. Then try to build the ESL lib again.
Once built, use make phpmod-install to install it.
Problem
I am learning to create a php extension. I have created a php extension for a basic hello world app. But the moment I try to include functions from the C library I am trying to entend then I get the following error message:
PHP Warning: PHP Startup: Unable to load dynamic library '/usr/lib/php5/20121212/hello.so' - /usr/lib/php5/20121212/hello.so: undefined symbol: nc_open in Unknown on line 0
This nc_open() function is the key function in the libary I am trying to extend
Process
I have created by header and config files and my c extension file which contains:
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include "php.h"
#include "php_hello.h"
#include <netcdf.h>
...
PHP_FUNCTION(hello_world)
{
int status;
int ncid;
status = nc_open("sample.nc", 0, &ncid);
RETURN_LONG(status);
}
I have set up a directory (on Ubuntu) and run the phpize and configure steps. I run the make command which runs with no errors.
In my php.ini file I have the hello.so extension which points to symbolic link to the file I make.
I then restart the apache server on my local machine and then run:
php -r 'echo hello_world();'
and get:
- /usr/lib/php5/20121212/hello.so: undefined symbol: nc_open in Unknown on line 0
PHP Warning: Module 'xdebug' already loaded in Unknown on line 0
PHP Fatal error: Call to undefined function hello_world() in Command line code on line 1
PHP Stack trace:
PHP 1. {main}() Command line code:0
The error only occurs when I have a function from netcdf.h
The error does not occur from just having the include statement.
What I've tried:
Firstly I tried writing a basic c program to check that it would work, I managed to succeed by compiling it with:
gcc test.c -lnetcdf -o Test
and running ./Test
I tried using the following MakeFile
LDLIBS = -lnetcdf
but was unsuccessful.
What I would like:
Preferably to know how to get this library to work in my extension but I would settle for being pointed to documents or examples to help me understand what I need to know to accomplish this.
Update
Following Elliott Frisch's comments I have tried the
Setting the PHP_RPATHS=/usr/local
Setting /etc/ld.so.conf to:
include /etc/ld.so.conf.d/*.conf
/usr/lib
Changing the MakeFile to:
LDLIBS = -lnetcdf
LDFLAGS = -static
I am making the assumption that /usr/local is the correct directory due to it containing netcdf.so
I have added the following lines to my config.m4 file according to try adding the suggested functions
PHP_ADD_INCLUDE(/usr/lib)
PHP_ADD_LIBRARY_WITH_PATH(netcdf, /usr/lib, HELLO_SHARED_LIBADD)
Unfortunately I am still getting the problem so I am trying to understand what these functions mean to make sure I using them correctly. (The library I need to connect to is /usr/lib/libnetcdf.a and need to include netcdf.h from that file.)
You'll need to use PHP_ADD_LIBRARY_WITH_PATH & PHP_ADD_INCLUDE macros in config.m4 to handle linking. Autoconf's macros are also helpful for find & verifying existing libraries.
The best examples can be found in the ext directory of PHP's source code. Like ext/zlib
PHP_ADD_LIBPATH($ZLIB_DIR/$PHP_LIBDIR, ZLIB_SHARED_LIBADD)
PHP_ZLIB_DIR=$ZLIB_DIR
PHP_ADD_LIBRARY(z,, ZLIB_SHARED_LIBADD)
PHP_ADD_INCLUDE($ZLIB_INCDIR)
And more detailed examples in ext/oracle (from apple's open source labs)
PHP_ADD_LIBRARY(clntsh, 1, ORACLE_SHARED_LIBADD)
PHP_ADD_LIBPATH($ORACLE_DIR/lib, ORACLE_SHARED_LIBADD)
The issue was with an incorrectly configured config.m4 file.
I added the following that I modified from examples I found to get it to work:
if test "$PHP_HELLO" != "no"; then
SEARCH_PATH="/usr/local /usr" # you might want to change this
SEARCH_FOR="/include/netcdf.h" # you most likely want to change this
if test -r $PHP_HELLO/$SEARCH_FOR; then # path given as parameter
HELLO_INC_DIR=$PHP_HELLO/include
else # search default path list
AC_MSG_CHECKING([for netcdf.h in default path])
for i in $SEARCH_PATH ; do
if test -r $i/$SEARCH_FOR; then
HELLO_INC_DIR=$i/include
AC_MSG_RESULT(found in $i)
fi
done
fi
if test -z "$HELLO_INC_DIR"; then
AC_MSG_RESULT([not found])
fi
SEARCH_PATH="/usr/local /usr" # you might want to change this
SEARCH_FOR="/lib/libnetcdf.a" # you most likely want to change this
if test -r $PHP_HELLO/$SEARCH_FOR; then # path given as parameter
HELLO_LIB_DIR=$PHP_HELLO/lib
else # search default path list
AC_MSG_CHECKING([for libnetcdf in default path])
for i in $SEARCH_PATH ; do
if test -r $i/$SEARCH_FOR; then
HELLO_LIB_DIR=$i/lib
AC_MSG_RESULT(found in $i)
fi
done
fi
if test -z "$HELLO_LIB_DIR"; then
AC_MSG_RESULT([not found])
AC_MSG_ERROR([Please check the netCDF distribution])
fi
# --with-netcdf -> add include path
PHP_ADD_INCLUDE($HELLO_INC_DIR)
# --with-netcdf -> check for lib and symbol presence
LIBNAME=netcdf # you may want to change this
dnl O_LDFLAGS=$LDFLAGS
dnl LDFLAGS="$LDFLAGS -L$NETCDF_LIB_DIR -l$LIBNAME"
PHP_ADD_LIBRARY($LIBNAME)
LIBSYMBOL=nc_inq_libvers # you most likely want to change this
PHP_CHECK_LIBRARY($LIBNAME,$LIBSYMBOL,
[
PHP_ADD_LIBRARY($LIBNAME)
AC_DEFINE(HAVE_HELLO,1,[Build netCDF extension])
],[
AC_MSG_ERROR([wrong netCDF library version or lib not found])
])
PHP_SUBST(HELLO_SHARED_LIBADD)
HELLO_SHARED_LIBADD=-l$LIBNAME