0.前言
Apache可移植运行时(Apache Portable Runtime,简称APR)是ApacheHTTP服务器的支持库,提供了一组映射到下层操作系统的API。如果操作系统不支持某个特定的功能,APR将提供一个模拟的实现。这样程序员使用APR编写真正可在不同平台上移植的程序。最初,APR是作为Apache HTTP服务器的一部分而存在的,但是Apache软件基金会将其延伸成一个单独的项目。其他的应用程序可以使用APR来实现平台无关性 (baidu)。
1.源码下载
APR包括三个源码包,分别为APR 1.7.0 , APR-util 1.6.1 ,APR iconv 1.2.2
源码下载链接https://apr.apache.org/download.cgi
2.编译
2.1 APR 1.7.0编译
./configure CC=arm-himix200-linux-gcc --host=arm-himix200-linux --prefix=$PWD/_install ac_cv_file__dev_zero=yes ac_cv_func_setpgrp_void=yes apr_cv_tcp_nodelay_with_cork=yes
make;make install
错误1:如果不加ac_cv_file__dev_zero=yes 会报如下错误
checking for /dev/zero... configure: error: cannot check for file existence when cross compiling
错误2:屏蔽configure 屏蔽掉$RM "$cfgfile"
rm: cannot remove 'libtoolT': No such file or directory
错误3:解决方案把该定义屏蔽掉即可。
./include/apr_want.h:94:8: error: redefinition of 'struct iovec'
错误4:进入tools下重新编译gcc -Wall -O2 -DCROSS_COMPILE gen_test_char.c -s -o gen_test_char
tools/gen_test_char > include/private/apr_escape_test_char.h
/bin/sh: tools/gen_test_char: 无法执行二进制文件
make[1]: *** [include/private/apr_escape_test_char.h] Error 126
接下来就可以完成编译;然后make install,生成目录如下:
bin build-1 include lib
2.2 APR iconv 1.2.2编译
./configure CC=arm-himix200-linux-gcc --host=arm-himix200-linux --prefix=$PWD/_instal --with-apr=$PWD/../apr-1.7.0/_install
make;make install
这个比较顺利,没有报什么错误。
2.3 APR-util 1.6.1编译
该库需要上面两个安装目录
./configure CC=arm-himix200-linux-gcc --host=arm-himix200-linux --prefix=$PWD/_instal --with-apr=$PWD/../apr-1.7.0/_install --with-apr-iconv=$PWD/../apr-iconv-1.2.2/_install --with-expat=$PWD/../libexpat-master/expat/_install
make;make install
错误1:需要安装expat库 --with-expat=库路径
xml/apr_xml.c:35:19: fatal error: expat.h: No such file or directory
#include <expat.h>
2.4 libexpat编译
由于APR-util需要用到该库,所以也把这个加上。
源码:https://github.com/libexpat/libexpat
编译:
./buildconf.sh
./configure CC=arm-himix200-linux-gcc --host=arm-himix200-linux --prefix=$PWD/_install
make; make install