开发者

Cross compiling php

I'm trying to cross compile php for arm and have good progress but I'm totally stuck where it wants to run the php itself (have no idea why). as it is an arm binary and not intel (my building platform) it won't run:

/bin/sh: /path-to-build/sapi/cli/php: cannot execute binary file

How can I fix this? The configure script understood I'm cross compiling but didn't do anything about it (from configure log):

checking whether the C compiler (/path-to-compiler/arm-none-linux-gnueabi-gcc) is a cross-compiler... yes

I'm compiling php-5.3.6 with configure command line:

export CC=/path-to-cc/arm-none-linux-gnueabi-gcc
../configure --prefix=/prefix-path/ --host=arm-none-linux-gnueabi
             --disable-libxml --disable-dom --disable-openssl
     开发者_C百科        --without-iconv --without-openssl --disable-simplexml
             --disable-xml --disable-xmlreader --disable-xmlwriter
             --without-pear --without-sqlite --without-sqlite3
             --disable-pdo --without-pdo-sqlite


I was able to resolve this my own by disabling phar. I hope disabling so much modules won't break something internal.


Build without cross compiling and then, when cross compiling, point to the host version of php by overrididing a variable in the makefile on the command line when running make.

Something like:

make PHP_VAR_NAME=path to php built for host


I managed to compile PHP for arm with the following parameters:

export PATH="$PATH:/toolchains/gnu_cortex-a9_tools/usr/bin" 
export ARCH=arm

configure script:

./configure --build=x86_64-unknown-linux-gnu --host=arm-linux-uclibcgnueabi --prefix=/usr/arm CC="arm-linux-uclibcgnueabi-gcc --sysroot=/toolchains/gnu_cortex-a9_tools/"  --disable-libxml --disable-dom  --without-iconv --without-openssl --disable-simplexml --disable-xml --disable-xmlreader --disable-xmlwriter --without-pear --without-sqlite3 --disable-pdo --without-pdo-sqlite --disable-phar

followed by

make


I managed to solve similar issue while cross-compiling PHP 5.6.0 by editing Makefile after running configure script. Just replace all occurrences of

$(top_builddir)/$(SAPI_CLI_PATH)

with

/usr/bin/php

Where /usr/bin/php is your host php cli. Make sure it is installed, e.g., sudo apt-get install php5-cli for Debian/Ubuntu.

After doing so phar extension builds fine

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜