apache - 针对 ARM 问题交叉编译 Apache

标签 apache arm ubuntu-14.04 cross-compiling

我正在尝试使用 Ubuntu 14.04 32 位虚拟机为 ARM 系统交叉编译 Apache。我能够构建所有必需的库(PCRE、APR、APR-Util、Libtool)并且配置脚本将运行良好。但是,当我运行 make 命令时,我收到以下错误。在这一点上,我完全不知道该怎么做才能解决这个问题。

util.c: In function ‘ap_parse_token_list_strict’:
util.c:1528:14: error: ‘T_HTTP_TOKEN_STOP’ undeclared (first use in this 
function)
util.c:1528:14: note: each undeclared identifier is reported only once for 
each function it appears in
util.c: In function ‘ap_scan_http_field_content’:
util.c:1602:14: error: ‘T_HTTP_CTRLS’ undeclared (first use in this 
function)
util.c: In function ‘ap_scan_http_token’:
util.c:1612:14: error: ‘T_HTTP_TOKEN_STOP’ undeclared (first use in this 
function)
util.c: In function ‘ap_scan_vchar_obstext’:
util.c:1622:13: error: ‘T_VCHAR_OBSTEXT’ undeclared (first use in this 
function)
util.c: In function ‘ap_find_token’:
util.c:1683:22: error: ‘T_HTTP_TOKEN_STOP’ undeclared (first use in this 
function)
util.c: In function ‘ap_escape_logitem’:
util.c:2092:13: error: ‘T_ESCAPE_LOGITEM’ undeclared (first use in this 
function)
util.c: In function ‘ap_escape_errorlog_item’:
util.c:2162:13: error: ‘T_ESCAPE_LOGITEM’ undeclared (first use in this 
function)
util.c: In function ‘ap_append_pid’:
util.c:2480:25: warning: format ‘%lld’ expects argument of type ‘long long 
int’, but argument 5 has type ‘__pid_t’ [-Wformat]
make[2]: *** [util.lo] Error 1

这是我用来配置的脚本

#!/bin/sh
export PATH=$PATH
export ARCH=armv7l
export CROSS_COMPILE=arm-linux-gnueabi-
export CC=arm-linux-gnueabi-gcc
export LD=arm-linux-gnueabi-ld
export LD_LIBRARY=/home/kyle/httpd/srclib/expat/bin
export CXX=arm-linux-gnueabi-g++
export AR=arm-linux-gnueabi-ar
export CPP=arm-linux-gnueabi-cpp
export STRIP=arm-linux-gnueabi-strip
export CC_FOR_BUILD=i686-linux-gnu-gcc
./configure \
    --host=arm-linux-gnueabi \
    --target=arm-linux-gnueabi \
    --prefix=/home/kyle/httpd \
    --build=i686-cross-linux-gnu \
    --with-apr=/home/kyle/httpd/srclib/apr \
    --with-apr-util=/home/kyle/httpd/srclib/apr-util \
    --with-pcre=/home/kyle/httpd/srclib/pcre \
    --with-expat=/home/kyle/httpd/srclib/expat \
    --disable-libtool-lock \
    ac_cv_file__dev_zero=no \
    ac_cv_func_setpgrp_void=no \
    apr_cv_tcp_nodelay_with_cork=no \
    ap_cv_void_ptr_lt_long=4 \
    ac_cv_sizeof_struct_iovec=1 

****编辑:我相信我已经找到了解决方案****

问题是我从 APR 复制了 gen_test_char 来绕过它的已知错误,但这与 httpd/server 中的 gen_test_char 不同。因此,一个简单的解决方法是运行 make 命令,等待它因 gen_test_char 格式错误而失败,然后运行

gcc gen_test_char.c -I"(where ever apr is)/apr/include" -o gen_test_char

这次运行后再次 make,一切都应该工作。

最佳答案

导出您的工具链路径

export PATH=$PATH:/usr/local/linaro-aarch64-2017.08-gcc7.1/bin

---------------------------------------- pcre 的步骤- 8.43 --------------------------------------

tar xvjf pcre-8.43.tar.bz2
cd pcre-8.43
./configure --prefix=/mnt/flash2/apache2_server --host=aarch64-linux-gnu CC=aarch64-linux-gnu-gcc AR=aarch64-linux-gnu-gcc-ar STRIP=aarch64-linux-gnu-strip RANLIB=aarch64-linux-gnu-ranlib 
make
make install DESTDIR=/home/ahmcpu2176/Downloads/apache2_server
cd ..

---------------------------------------- libexpat 的步骤- R_2_2_9 --------------------------------------

tar xvzf libexpat-R_2_2_9.tar.gz
cd libexpat-R_2_2_9/expat
./buildconf.sh
./configure --prefix=/mnt/flash2/apache2_server --host=aarch64-linux-gnu CC=aarch64-linux-gnu-gcc AR=aarch64-linux-gnu-gcc-ar STRIP=aarch64-linux-gnu-strip RANLIB=aarch64-linux-gnu-ranlib 
make
make install DESTDIR=/home/ahmcpu2176/Downloads/apache2_server
cd ../..

------------------------ httpd-2.4.23 的步骤(apache2 和 apr、apr-util、pcre) --------------------------

下载apr-1.5.0和apr-util-1.6.1库并将压缩文件解压到

httpd-2.4.23/srclib
tar xvzf httpd-2.4.23.tar.gz
tar xvzf apr-1.5.0.tar.gz
tar xvjf apr-util-1.6.1.tar.bz2
mv apr-1.5.0 httpd-2.4.23/srclib/apr
mv apr-util-1.6.1 httpd-2.4.23/srclib/apr-util
cd httpd-2.4.23
./configure --prefix=/mnt/flash2/apache2_server --target=aarch64-linux-gnu --host=aarch64-linux-gnu CC=aarch64-linux-gnu-gcc CPP=aarch64-linux-gnu-cpp CXX=aarch64-linux-gnu-c++ AR=aarch64-linux-gnu-gcc-ar STRIP=aarch64-linux-gnu-strip RANLIB=aarch64-linux-gnu-ranlib --with-included-apr --with-pcre=/home/ahmcpu2176/Downloads/pcre-8.43/pcre-config --with-expat=/home/ahmcpu2176/Downloads/apache2_server/mnt/flash2/apache2_server ac_cv_func_setpgrp_void="no" ap_cv_void_ptr_lt_long=4 ac_cv_file__dev_zero="yes" ac_cv_func_setpgrp_void="yes" apr_cv_process_shared_works="yes" apr_cv_mutex_robust_shared="no" apr_cv_tcp_nodelay_with_cork="yes" ac_cv_sizeof_struct_iovec="8" apr_cv_mutex_recursive="yes" --enable-mpms-shared=all --with-mpm=event
make

--------如果出现以下错误------
/bin/bash: tools/gen_test_char: 无法执行二进制文件: Exec 格式错误
Makefile:137: 目标“include/private/apr_escape_test_char.h”的配方失败
make[1]: * [include/private/apr_escape_test_char.h] 错误126
make[1]: 离开目录 '/home/ahmcpu2176/Downloads/apr-1.5.0'
/home/ahmcpu2176/Downloads/apr-1.5.0/build/apr_rules.mk:118: 目标“全递归”的配方失败
make: *
[全递归]错误1

--------解决方案--------

cd srclib/apr/tools
gcc -Wall -O2 -DCROSS_COMPILE gen_test_char.c -s -o gen_test_char
cd ../../..
make

--------如果出现如下错误--------
/home/ahmcpu2176/Downloads/httpd-2.4.23/srclib/apr/libtool --silent --mode=link aarch64-linux-gnu-gcc -g -O2 -L/home/ahmcpu2176/Downloads/apache2_server/mnt/flash2/apache2_server/lib -o gen_test_char -L/home/ahmcpu2176/Downloads/apache2_server/mnt/flash2/apache2_server/lib gen_test_char.lo
./gen_test_char > test_char.h
/bin/bash: ./gen_test_char: 无法执行二进制文件: Exec 格式错误
Makefile:36: 目标“test_char.h”的配方失败
make[2]: * [test_char.h] 错误 126
make[2]: 离开目录 '/home/ahmcpu2176/Downloads/httpd-2.4.23/server'
/home/ahmcpu2176/Downloads/httpd-2.4.23/build/rules.mk:75: 目标“all-recursive”的配方失败
make[1]: *
[全递归] 错误 1
make[1]: 离开目录'/home/ahmcpu2176/Downloads/httpd-2.4.23/server'
/home/ahmcpu2176/Downloads/httpd-2.4.23/build/rules.mk:75: 目标“all-recursive”的配方失败
make: *** [all-recursive] 错误 1

--------解决方案--------

cd server 
gcc gen_test_char.c -I./../srclib/apr/include/ -o gen_test_char
cd ..
make
make install DESTDIR=/home/ahmcpu2176/Downloads/apache2_server
cd ..
tar cvzf apache2_server.tar.gz apache2_server

关于apache - 针对 ARM 问题交叉编译 Apache,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46367076/

相关文章:

c++ - 在 ARM 上混合使用 uint64_t 和 long 会产生奇怪的结果

linux - 如何在 ARM 程序集中打印数字?

python-3.x - 如何在不出现在统一面板或 alt-tab 中的情况下运行 python tkinter 应用程序

php - 将动态网址转换为静态网址

django - 使用 pip install 出现异常

django - 来源 : not found error while running shell script on ubuntu 14. 04

php - httpd.conf 虚拟主机不工作

html - 随机文章按钮

windows - 我正在使用 Window Server 2008 VPS,当用户输入 IP 地址时,如何使它转到 Tomcat 页面而不是 IIS 页面?