下载源码
apr版本apr-1.7.0
https://apr.apache.org/download.cgi?spm=a2c4g.11186623.0.0.7aa126fdh2V87j&file=download.cgi
编译安装源码
#先用gcc编译生成gen_test_char,交叉编译的时候要用
$ ./configure --prefix=/opt/armlib_mipsel/libapr --host=x86_64 CC=gcc
$ make
$ cp tools/gen_test_char /opt/tmp #零时保存执行文件
$./configure --prefix=/opt/armlib_mipsel/libapr --host=mipsel-openwrt-linux CC=mipsel-openwrt-linux-gcc ac_cv_file__dev_zero=yes ac_cv_func_setpgrp_void=yes apr_cv_tcp_nodelay_with_cork=yes ac_cv_sizeof_struct_iovec=8
$ make clean
$ cp /opt/tmp/gen_test_char tools
$ make
$ make install
全过程问题记录
配置完工具链和安装路径直接configure报错
$ ./configure --prefix=/opt/armlib_mipsel/libapr --host=mipsel-openwrt-linux CC=mipsel-openwrt-linux-gcc
...
checking for /dev/zero... configure: error: cannot check for file existence when cross compiling
解决:增加 ac_cv_file__dev_zero=yes
$ ./configure --prefix=/opt/armlib_mipsel/libapr --host=mipsel-openwrt-linux CC=mipsel-openwrt-linux-gcc ac_cv_file__dev_zero=yes
换了一改错,接着干
checking whether setpgrp takes no argument... configure: error: cannot check setpgrp when cross compiling
解决:增加 ac_cv_func_setpgrp_void=yes
$ ./configure --prefix=/opt/armlib_mipsel/libapr --host=mipsel-openwrt-linux CC=mipsel-openwrt-linux-gcc ac_cv_file__dev_zero=yes ac_cv_func_setpgrp_void=yes
又换了错,继续搞
checking whether TCP_NODELAY and TCP_CORK can both be enabled... configure: error: in `/opt/armsrc/apr-1.7.0':
configure: error: cannot run test program while cross compiling
See `config.log' for more details
解决:增加 apr_cv_tcp_nodelay_with_cork=yes
& ./configure --prefix=/opt/armlib_mipsel/libapr --host=mipsel-openwrt-linux CC=mipsel-openwrt-linux-gcc ac_cv_file__dev_zero=yes ac_cv_func_setpgrp_void=yes apr_cv_tcp_nodelay_with_cork=yes
哎,还有问题
config.status: executing libtool commands
rm: cannot remove 'libtoolT': No such file or directory
config.status: executing default commands
config.status: include/apr.h is unchanged
config.status: include/arch/unix/apr_private.h is unchanged
解决:注释掉
R
M
"
RM "
RM"cfgfile"
可以make了,又报错了
./include/apr_want.h:94:8: error: redefinition of 'struct iovec'
struct iovec
^
解决:增加ac_cv_sizeof_struct_iovec=8
$ ./configure --prefix=/opt/armlib_mipsel/libapr --host=mipsel-openwrt-linux CC=mipsel-openwrt-linux-gcc ac_cv_file__dev_zero=yes ac_cv_func_setpgrp_void=yes apr_cv_tcp_nodelay_with_cork=yes ac_cv_sizeof_struct_iovec=8
$ make
继续
/bin/bash: tools/gen_test_char: cannot execute binary file: Exec format error
Makefile:143: recipe for target 'include/private/apr_escape_test_char.h' failed
make[1]: *** [include/private/apr_escape_test_char.h] Error 126
make[1]: Leaving directory '/opt/armsrc/apr-1.7.0'
/opt/armsrc/apr-1.7.0/build/apr_rules.mk:118: recipe for target 'all-recursive' failed
make: *** [all-recursive] Error 1
解决:使用gcc先编译出gen_test_char,然后再编译目标系统
$ ./configure --prefix=/opt/armlib_mipsel/libapr --host=x86_64 CC=gcc
$ make clean
$ make
$ cp tools/gen_test_char /opt/tmp #零时保存执行文件
$./configure --prefix=/opt/armlib_mipsel/libapr --host=mipsel-openwrt-linux CC=mipsel-openwrt-linux-gcc ac_cv_file__dev_zero=yes ac_cv_func_setpgrp_void=yes apr_cv_tcp_nodelay_with_cork=yes ac_cv_sizeof_struct_iovec=8
$ make clean
$ cp /opt/tmp/gen_test_char tools
$ make
最后 make install 就可以了