适配龙芯平台的Apache交叉编译

适配龙芯平台的Apache交叉编译

下载Apache源码:

  • 从http://www.apache.org/ 上下载apache_1.3.39.tar.gz,然后解压缩的一个目录,然后转到apache_1.3.39目录。
  • 我这边下载了httpd-2.4.41…tar.gz的包,解压后:
    在这里插入图片描述

编译安装

  • 执行:./configure
  • 【报错】:configure: error: APR not found. Please read the documentation.
    • 【解决方法】:缺乏依赖的APR源码包,下载安装:https://apr.apache.org/download.cgi
  • 【报错】:checking for APR-util… no
    • 【解决方法】:缺乏依赖的APR-UTIL安装包,继续下载安装对应的包。

安装依赖的APR包:

  • 下载对应的APR源码包:https://apr.apache.org/download.cgi
  • 解压:tar -xvf apr-1.7.0.tar.gz
./configure --prefix=/home/ww/Apache/mips-apr
make
make install

安装依赖的APR-UTIL包:

  • 下载依赖包:https://mirrors.tuna.tsinghua.edu.cn/apache//apr/apr-util-1.6.1.tar.gz
tar -xvf apr-util-1.6.1.tar.gz 
mkdir x86-apr-util
./configure --prefix=/home/ww/Apache/x86-apr-util/ --with-apr=/home/ww/Apache/x86-apr/bin/apr-1-config
make
make install

安装完成依赖库后继续安装

./configure --with-apr=/home/ww/Apache/x86-apr --with-apr-util=/home/ww/Apache/x86-apr-util
  • 显示
    适配龙芯平台的Apache交叉编译_第1张图片
make
make install
  • 此时,完成了x86平台下的源码安装,但是我们需要的是使用龙芯mips编译器编译的龙芯平台下使用的Apache运行环境,所以还需要回到开始的状态继续配置安装。

龙芯平台下的MIPS交叉编译Apache

  • 配置:
./configure --with-apr=/home/ww/Apache/x86-apr --with-apr-util=/home/ww/Apache/x86-apr-util --host=mips

  • 【报错】
checking for chosen layout... Apache
checking for working mkdir -p... yes
checking for grep that handles long lines and -e... /bin/grep
checking for egrep... /bin/grep -E
checking build system type... x86_64-pc-linux-gnu
checking host system type... mips-unknown-elf
checking target system type... mips-unknown-elf
configure: 
configure: Configuring Apache Portable Runtime library...
configure: 
checking for APR... yes
  setting CFLAGS to " -g -O2 -pthread"
  setting CPPFLAGS to " -DLINUX -D_REENTRANT -D_GNU_SOURCE"
  setting LDFLAGS to " "
configure: 
configure: Configuring Apache Portable Runtime Utility library...
configure: 
checking for APR-util... yes
checking for mips-gcc... mips64el-linux-gcc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables... 
checking whether we are cross compiling... yes
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether mips64el-linux-gcc accepts -g... yes
checking for mips64el-linux-gcc option to accept ISO C89... none needed
checking how to run the C preprocessor... mips64el-linux-g++
configure: error: in `/home/ww/Apache/httpd-2.4.41':
configure: error: C preprocessor "mips64el-linux-g++" fails sanity check
See `config.log' for more details
  • 应该是没有编译对应平台下的APR、apr-uttil库,使用交叉编译器重新编译对应平台下的APR库及apr-util库。

交叉编译Apr库

cd apr-1.7.0
sudo ./configure --prefix=/home/ww/Apache/mips-apr --host=mips CC=/opt/opt/gcc-4.9.3-64-gnu/bin/mips64el-linux-gcc CXX=/opt/opt/gcc-4.9.3-64-gnu/bin/mips64el-linux-g++ LD=/opt/opt/gcc-4.9.3-64-gnu/bin/mips64el-linux-ld ac_cv_file__dev_zero=yes ac_cv_func_setpgrp_void=yes apr_cv_tcp_nodelay_with_cork=yes --cache=mips64el-linux.cache
make
  • 【报错】:
In file included from ./include/apr_strings.h:52:0,
                 from encoding/apr_encode.c:30:
./include/apr_want.h:94:8: error: redefinition of 'struct iovec'
 struct iovec
        ^
In file included from /opt/opt/gcc-4.9.3-64-gnu/sysroot/usr/include/sys/uio.h:28:0,
                 from /opt/opt/gcc-4.9.3-64-gnu/sysroot/usr/include/sys/socket.h:26,
                 from ./include/apr.h:169,
                 from ./include/apr_encode.h:24,
                 from encoding/apr_encode.c:28:
/opt/opt/gcc-4.9.3-64-gnu/sysroot/usr/include/bits/uio.h:43:8: note: originally defined here
 struct iovec

修改mips64el-linux.cache中的内容:

apr_cv_process_shared_works=yes
apr_cv_mutex_robust_shared=yes
ac_cv_sizeof_struct_iovec=8
  • 继续configure配置。
  • 【报错】:
    安装apache的依赖apr时报rm: cannot remove ‘libtoolT’: No such file or directory的错

编辑configure
找到RM" RM “RM"cfgfile” 将其注释掉即可

$RM "$cfgfile" 将其注释即可

最后还是没能成功编译完成。

  • 不过借助buildroot工具包,成功在这里完成了MIPS龙芯平台下的Apache运行环境的编译。
  • 哎。。。。

你可能感兴趣的:(嵌入式相关基础知识)