PHP cross compilation failure - php

I try to cross compile PHP 5.3.25 for arm-merlin on x86_64 linux.
My configure command looks like the following:
export CC=/opt/mobilygen/tools/arm-merlin-linux-uclibc/i686-linux/bin/arm-merlin-linux-uclibc-gcc
./configure --prefix=/opt/php --host=arm-merlin-linux-uclibc --target=arm-merlin-linux-uclibc --build=x86_64-linux --without-iconv --without-pear --disable-ipv6 --without-openssl --without-sqlite --without-sqlite3 --disable-pdo --without-pdo-sqlite --with-libxml-dir=/opt/libxml2/ --includedir=/opt/mobilygen/tools/arm-merlin-linux-uclibc-SDK7r4552/i686-linux/arm-merlin-linux-uclibc/usr/include
The linker fails with:
ext/standard/php_crypt_r.o: In function `_crypt_extended_init_r':
/projects/php/php-5.3.25/ext/standard/php_crypt_r.c:101: undefined reference to `membar_producer'
/projects/php/php-5.3.25/ext/standard/php_crypt_r.c:102: undefined reference to `atomic_add_int'
collect2: ld returned 1 exit status
make: *** [sapi/cgi/php-cgi] Error 1
It seems that the SDK doesn't provide the correct sys/atomic.h library.
Is there a workaround for this? It would be also ok if the MD5 functionality is stripped.

Related

/php_intl.h:33:10: fatal error: 'unicode/ubrk.h' file not found

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!!

ld: fatal: file /usr/local/lib/libiconv.so: wrong ELF class: ELFCLASS32

I'm trying to build PHP 7.4 on Solaris sparc 10, but I'm getting this error:
d_objects.lo Zend/zend_object_handlers.lo Zend/zend_objects_API.lo Zend/zend_default_classes.lo Zend/zend_inheritance.lo Zend/zend_smart_str.lo Zend/zend_cpuinfo.lo Zend/zend_execute.lo sapi/apache2handler/mod_php7.lo sapi/apache2handler/sapi_apache2.lo sapi/apache2handler/apache_config.lo sapi/apache2handler/php_functions.lo main/internal_functions.lo -lresolv -lrt -liconv -lintl -lrt -lm -lnsl -lsocket -lgcc -o libphp7.la
ld: fatal: file /usr/local/lib/libiconv.so: wrong ELF class: ELFCLASS32
ld: fatal: file processing errors. No output written to .libs/libphp7.so
*** Error code 1
make: Fatal error: Command failed for target `libphp7.la'
My configure is as follows:
./configure --disable-xmlwriter --disable-xmlreader --disable-simplexml --disable-xml --disable-dom --with-apxs2=/usr/apache2/bin/apxs --with-gd --with-zlib --disable-ipv6 --with-jpeg-dir=/usr/local --with-png-dir=/usr/local --with-freetype-dir=/usr/local --without-pear --with-openssl --with-mysqli --enable-bcmath --enable-ctype --enable-mbstring --with-gettext --prefix=/usr/php --without-libxml OPENSSL_CFLAGS=-I/usr/include/openssl OPENSSL_LIBS=-L/usr/local/ssl/include SQLITE_CFLAGS=-I/usr/php/include/php/ext SQLITE_LIBS=-L/usr/php/include/php/ext ZLIB_CFLAGS=-I/usr/include ZLIB_LIBS=-L/usr/include ONIG_CFLAGS=-I/usr/local/include/php/ext/mbstring ONIG_LIBS=-L/local/include/php/ext/mbstring
--with-external-pcre
--with-pcre-jit
PCRE2_LIBS=-L/app/INSTALL_FILES/php-7.4.13/ext/pcre/pcre2lib
PCRE2_CFLAGS=-I/app/INSTALL_FILES/php-7.4.13/ext/pcre/pcre2lib
SQLITE_LIBS=-L/app/INSTALL_FILES/php-7.2.5/ext/sqlite3/libsqlite
SQLITE_CFLAGS=-I/app/INSTALL_FILES/php-7.2.5/ext/sqlite3/libsqlite
Environment is set as follows:
$ env|grep LD
LDFLAGS=-L/opt/csw/lib/gcc -L/usr/local/lib -R/opt/csw/lib/gcc
LD_LIBRARY_PATH_64=/opt/csw/lib/sparcv9:/usr/local/64/lib:/usr/sfw/lib/sparcv9
LD_LIBRARY_PATH=/opt/csw/bin/sparcv9:/opt/csw/lib/sparcv9:/usr/local/include/php/ext/sqlite3/libsqlite:/opt/csw/lib:/usr/local/64/lib:/usr/sfw/lib/sparcv9:/usr/apache2.2/pcre/lib:/usr/apache2.2/apr_util/lib:/usr/apache2.2/apr/lib
LD_LIBRARY_PATH_32=/usr/local/include/php/ext/sqlite3/libsqlite:/opt/csw/lib:/usr/apache2.2/pcre/lib:/usr/apache2.2/apr_util/lib:/usr/apache2.2/apr/lib
Any help would be much appreciated, thanks in advance :)
You are building a 64-bit executable with the following environment variable set:
LD LDFLAGS=-L/opt/csw/lib/gcc -L/usr/local/lib -R/opt/csw/lib/gcc
Given this error:
ld: fatal: file /usr/local/lib/libiconv.so: wrong ELF class: ELFCLASS32
The shared object /usr/local/lib/libiconv.so is a 32-bit shared object.
You can either remove directories that have 32-bit binaries in them from your LD_* environment variables when building or running 64-bit binaries, or make sure the contents of any of those directories are all 32- or 64-bit if there's a 64-bit library in /usr/local/lib that you need.
You need to read the ENVIRONMENT VARIABLES section of the Solaris 10 ld.so.1 man page:
Environment Variables
Each environment variable can be specified with a _32 or _64
suffix. This makes the environment variable specific, respectively, to
32–bit or 64–bit processes. This environment variable overrides any
non-suffixed version of the environment variable that might be in
effect. Environment variables specified without a value, that have a
_32 or _64 suffix, effectively cancel any associated generic environment variable setting.
You're mixing a lot of LD_* environment variables with and without the _32 and _64 suffixes, and you need to clean that up and be consistent so you don't wind up mixing 32- and 64-bit executable files.
And this looks downright wrong:
ZLIB_LIBS=-L/usr/include
Libraries in /usr/include???

SOLVED: Compiling PHP with GD : relocation R_X86_64_PC32 against symbol `WebPMemoryWrite' can not be used when making a shared object;

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

Compile PHP extension using SWIG

I am trying to compile the swig interface of crfsuite as a PHP module. So far I've managed to actually compile a crfsuite.so file, load it as an extension in PHP and call methods on it. As far as I can see any method call that was wrapped by SWIG works fine out of the box. Unfortunately I seem to be missing some symbols:
❯ nm crfsuite.so | grep crfsuite
U crfsuite_attribute_set
U crfsuite_create_instance
U crfsuite_create_instance_from_file
U crfsuite_create_instance_from_memory
U crfsuite_data_append
U crfsuite_data_finish
U crfsuite_data_init
00000000000281b3 T crfsuite_dictionary_create_instance
U crfsuite_evaluation_accmulate
U crfsuite_evaluation_finalize
U crfsuite_evaluation_init
U crfsuite_evaluation_output
0000000000256460 B crfsuite_globals
U crfsuite_instance_finish
U crfsuite_instance_init_n
U crfsuite_interlocked_decrement
U crfsuite_interlocked_increment
U crfsuite_item_append_attribute
U crfsuite_item_init
U crfsuite_item_init_n
I have generated the swig wrapper like so, using the default export.i:
swig -c++ -php7 -Icrfsuite/include -o export_wrap.cpp export.i
After that I've compiled the code with the following commands:
gcc -fpic -Icrfsuite/include -Icrfsuite/lib/cqdb/include -Iliblbfgs/include \
`php-config --includes` -c crfsuite.cpp export_wrap.cpp crfsuite/lib/crf/src/*.c \
crfsuite/swig/*.cpp crfsuite/lib/cqdb/src/cqdb.c crfsuite/lib/cqdb/src/lookup3.c \
liblbfgs/lib/*.c
gcc -shared *.o -o crfsuite.so
I've played with many gcc flags such as -L/usr/local/lib, -lcrfsuite, -Wl,-undefined,dynamic_lookup but stopped as they didn't seem to affect the result.
Running a basic example errors with the following message:
/usr/bin/php: symbol lookup error: /usr/lib/php/20170718/crfsuite.so: undefined symbol: crfsuite_data_init
The example correctly calls the Trainer constructor.
This all is quite new so I am lost between the many steps. Am I missing something obvious? Why are the symbols not linked correctly? And how can it be fixed?
Update:
I've set the $LD_LIBRARY_PATH and $LD_RUN_PATH to /usr/local/lib. That is also where the compiled and installed version of the crfsuite lies as a shared object:
ll $LD_LIBRARY_PATH/libcrfsuite.so
/usr/local/lib/libcrfsuite.so -> libcrfsuite-0.12.so
I have also changed the order of .o files. Didn't change anything.

Cannot run PHP script under Tomcat

Am using Tomcat 6. I have installed PHP and try to get PHP running inside Tomcat with PHP/JavaBridge. I have deployed JavaBridge.war inside Tomcat's webapps directory. When running any PHP script, I will get this error below. Please help and I thank you for your assistance.
This was how I configure PHP:
./configure --with-mime-magic
--with-config-file-path=/usr/local/Zend/etc
--with-apxs2=/usr/local/apache2/bin/apxs
--with-libxml-dir=/usr
--with-mhash=/usr/local
--with-bz2=/usr
--with-curl=/usr
--with-gettext=/usr
--with-mysql=/usr/local/mysql
--with-mcrypt=/usr/local
--enable-magic-quotes
--enable-bcmath
--enable-calendar
--enable-ftp
--enable-sockets
--enable-wddx
--enable-mbstring
--enable-zip
--enable-exif
--with-gd=/usr
--with-freetype-dir=/usr
--with-jpeg-dir=/usr
--with-png-dir=/usr
--enable-gd-native-ttf
--enable-fastcgi
--enable-force-cgi-redirect
The error msgs from Tomcat as follows:
HTTP Status 500 -
type Exception report
message
description The server encountered an internal error () that prevented
it from fulfilling this request.
exception
javax.servlet.ServletException:
php.java.bridge.http.FCGIConnectException: Could not connect to server
php.java.servlet.fastcgi.FastCGIServlet.init(FastCGIServlet.java:133)
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298)
org.apache.coyote.http11.Http11AprProcessor.process(Http11AprProcessor.java:861)
org.apache.coyote.http11.Http11AprProtocol$Http11ConnectionHandler.process(Http11AprProtocol.java:579)
org.apache.tomcat.util.net.AprEndpoint$Worker.run(AprEndpoint.java:1584)
java.lang.Thread.run(Thread.java:662) root cause
php.java.bridge.http.FCGIConnectException: Could not connect to server
php.java.bridge.http.SocketChannelFactory.test(SocketChannelFactory.java:58)
php.java.servlet.fastcgi.FastCGIServlet.init(FastCGIServlet.java:131)
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298)
org.apache.coyote.http11.Http11AprProcessor.process(Http11AprProcessor.java:861)
org.apache.coyote.http11.Http11AprProtocol$Http11ConnectionHandler.process(Http11AprProtocol.java:579)
org.apache.tomcat.util.net.AprEndpoint$Worker.run(AprEndpoint.java:1584)
java.lang.Thread.run(Thread.java:662) root cause
java.io.IOException: java.net.ConnectException: Connection refused
php.java.bridge.http.FCGIConnectException.(FCGIConnectException.java:37)
php.java.bridge.http.SocketChannelFactory.test(SocketChannelFactory.java:58)
php.java.servlet.fastcgi.FastCGIServlet.init(FastCGIServlet.java:131)
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298)
org.apache.coyote.http11.Http11AprProcessor.process(Http11AprProcessor.java:861)
org.apache.coyote.http11.Http11AprProtocol$Http11ConnectionHandler.process(Http11AprProtocol.java:579)
org.apache.tomcat.util.net.AprEndpoint$Worker.run(AprEndpoint.java:1584)
java.lang.Thread.run(Thread.java:662) root cause
java.io.IOException: PHP not found. Please install php-cgi. PHP test
command was: [php-cgi, -v]
php.java.bridge.Util$Process.start(Util.java:1145)
php.java.servlet.fastcgi.FCGIProcess.start(FCGIProcess.java:68)
php.java.bridge.http.SocketChannelFactory.doBind(SocketChannelFactory.java:125)
php.java.bridge.http.FCGIConnectionFactory.runFcgi(FCGIConnectionFactory.java:88)
php.java.bridge.http.FCGIConnectionFactory$1.run(FCGIConnectionFactory.java:109)
note The full stack trace of the root cause is available in the Apache
Tomcat/6.0.29 logs.
Apache Tomcat/6.0.29
I had the same error as yours,
the key point you are missing here is :
PHP CLI(Command Line Interface) needs to be setup to work with java-php
bridge
as you claim to have installed PHP(any means XAMPP/WAMP)
Go through the following steps :
Add PHP to PATH environment variable - Help
Confirm the configuration by Run CMD>
php-cgi -v
By the above command you will see PHP version info
Restart Tomcat
PHP/JavaBridge should start working after this.
I had the same problem. Another suggestion had been to add
-Dphp.java.bridge.php_exec=/usr/bin/php
to the command line. Instead, I modified the JAVA_OPTS export in my catalina.sh file to add it. That didn't work, but I combined it with the suggestion above and added
-Dphp.java.bridge.php_exec=/usr/bin/php-cgi
to catalina.sh. I bounced the server and connected to server/JavaBridgeTemplate621/ and got the PHP/Java Bridge settings page.
Reinstall and enable fastcgi it worked for me!

Categories