交叉编译php

时间:2011-07-02 20:37:24

标签: php cross-compiling

我正在尝试交叉编译php for arm并取得了很好的进展,但我完全陷入了想要运行php本身的地方(不知道为什么)。因为它是一个arm二进制而不是intel(我的构建平台)它不会运行:

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

我该如何解决这个问题?配置脚本理解我正在交叉编译但没有做任何事情(来自配置日志):

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

我正在使用configure命令行编译php-5.3.6

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
             --without-iconv --without-openssl --disable-simplexml
             --disable-xml --disable-xmlreader --disable-xmlwriter
             --without-pear --without-sqlite --without-sqlite3
             --disable-pdo --without-pdo-sqlite

4 个答案:

答案 0 :(得分:5)

我可以通过禁用phar来解决此问题。我希望禁用这么多模块不会破坏内部的东西。

答案 1 :(得分:2)

在没有交叉编译的情况下构建,然后在交叉编译时,通过在运行make时在命令行上覆盖makefile中的变量来指向php的主机版本。

类似的东西:

make PHP_VAR_NAME=path to php built for host

答案 2 :(得分:1)

我设法使用以下参数编译PHP for arm:

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

配置脚本:

./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

接着是

make

答案 3 :(得分:1)

我在运行Makefile脚本后通过编辑configure来交叉编译PHP 5.6.0时设法解决了类似的问题。只需替换所有出现的

  

$(top_builddir)/ $(SAPI_CLI_PATH)

  

的/ usr / bin中/ PHP的

/usr/bin/php是您的主机php cli。确保它已安装,例如,sudo apt-get install php5-cli用于Debian / Ubuntu。

这样做之后,phar扩展就可以了。

相关问题