编译环境说明
系统: deepin V20
平台:x86_64
交叉编译器:mips-loongson-gcc7.3-linux-gnu
本机gcc
版本:gcc version 8.3.0
交叉编译环境搭建
交叉编译环境搭建见在x86_64平台上搭建龙芯MIPS64交叉编译环境
安装编译工具
# 安装cmake
sudo apt install cmake
获取源代码
下载zlib
源代码压缩包
下载地址 。
使用git签出源代码
# 国内加速镜像站
git clone https://gitee.com/mirrors/zlib.git
# github
git clone https://github.com/madler/zlib.git
编译
以下以v1.2.11
版示例交叉编译zlib
。
# 进入源代码目录
cd zlib
git checkout v1.2.11
# 配置编译环境
mkdir build
cd build
cmake -DCMAKE_C_COMPILER=mips-linux-gnu-gcc -DCMAKE_INSTALL_PREFIX=/opt/mips/zlib ../
# 编译及安装
make -j4
make install
说明:在deepin15.11系统上,我个人使用gcc4.4.7编译器交叉编译通过,并且没有使用cmake,但是在deepin V20系统上却编译不同过,并且使用cmake,也无法通过编译;使用gcc7.3编译器时,不使用cmake,执行configure就报错,使用cmake则可以编译通过
以下是在deepin 15.11
系统上编译通过的
deepin 15.11编译环境说明
系统: deepin 15.11
平台:x86_64
交叉编译器:gcc-4.4.7-7215-n64-loongson
本机gcc
版本:gcc version 6.3.0
编译
以下以zlib-1.2.11
版示例交叉编译zlib
。
# 解压源代码
tar -xf zlib-1.2.11.tar.gz
# 进入源代码目录
cd zlib-1.2.11
# 配置编译环境
export LD_LIBRARY_PATH=/home/dev/App/gcc-4.4.7-7215-n64-loongson/usr/lib:/home/dev/App/gcc-4.4.7-loongson/usr/x86_64-unknown-linux-gnu/mips64el-redhat-linux/lib:$LD_LIBRARY_PATH
CC="/home/dev/App/gcc-4.4.7-7215-n64-loongson/usr/bin/mips64el-redhat-linux-gcc" ./configure --prefix=/opt/mips/zlib
# 编译及安装
make -j4
make install