OpenHarmony 开源鸿蒙南向开发——linux下使用make交叉编译第三方库——gnutls

发布于:2025-05-13 ⋅ 阅读:(13) ⋅ 点赞:(0)

 准备工作

请依照这篇文章搭建环境

OpenHarmony 开源鸿蒙南向开发——linux下使用make交叉编译第三方库——环境配置_openharmony交叉编译-CSDN博客

编译依赖

分别需要编译gmp、nettle、libunistring、libtasn、gettext

上述库可在历史文章中自行查找

下载

wget ftp://ftp.gnutls.org/gcrypt/gnutls/v3.5/gnutls-3.5.9.tar.xz

解压

tar -xf gnutls-3.5.9
cd gnutls-3.5.9
mkdir build

环境变量

这里要更换一下依赖库的目录

export OHOS_SDK=/home/vtstar/Desktop/openharmony/sdk/sdk_linux_5.0.0.71
export AS=${OHOS_SDK}/native/llvm/bin/llvm-as
export CC="${OHOS_SDK}/native/llvm/bin/clang --target=arm-linux-ohos"
export CXX="${OHOS_SDK}/native/llvm/bin/clang++ --target=arm-linux-ohos"
export LD=${OHOS_SDK}/native/llvm/bin/ld.lld
export STRIP=${OHOS_SDK}/native/llvm/bin/llvm-strip
export RANLIB=${OHOS_SDK}/native/llvm/bin/llvm-ranlib
export OBJDUMP=${OHOS_SDK}/native/llvm/bin/llvm-objdump
export OBJCOPY=${OHOS_SDK}/native/llvm/bin/llvm-objcopy
export NM=${OHOS_SDK}/native/llvm/bin/llvm-nm
export AR=${OHOS_SDK}/native/llvm/bin/llvm-ar
export CFLAGS="-fPIC -D__MUSL__=1 -march=armv7a -I/home/vtstar/Desktop/openharmony/ThirtyPartRestore/Libunistring/out/32/build/include -I/home/vtstar/Desktop/openharmony/ThirtyPartRestore/nettle/out/32/build/include -I/home/vtstar/Desktop/openharmony/ThirtyPartRestore/libtasn/out/32/build/include -I/home/vtstar/Desktop/openharmony/ThirtyPartRestore/gmp/out/32/include -I/home/vtstar/Desktop/openharmony/ThirtyPartRestore/gettext/out/32/build/include"
export CXXFLAGS="-fPIC -D__MUSL__=1 -march=armv7a   -I/home/vtstar/Desktop/openharmony/ThirtyPartRestore/Libunistring/out/32/build/include -I/home/vtstar/Desktop/openharmony/ThirtyPartRestore/nettle/out/32/build/include -I/home/vtstar/Desktop/openharmony/ThirtyPartRestore/libtasn/out/32/build/include -I/home/vtstar/Desktop/openharmony/ThirtyPartRestore/gmp/out/32/include -I/home/vtstar/Desktop/openharmony/ThirtyPartRestore/gettext/out/32/build/include"
export LDFLAGS="-L/home/vtstar/Desktop/openharmony/ThirtyPartRestore/gmp/out/32/lib -L/home/vtstar/Desktop/openharmony/ThirtyPartRestore/Libunistring/out/32/build/lib -L/home/vtstar/Desktop/openharmony/ThirtyPartRestore/nettle/out/32/build/lib -L/home/vtstar/Desktop/openharmony/ThirtyPartRestore/libtasn/out/32/build/lib -L/home/vtstar/Desktop/openharmony/ThirtyPartRestore/Libunistring/out/32/build/lib -L/home/vtstar/Desktop/openharmony/ThirtyPartRestore/gettext/out/32/build/lib"      

配置make

./configure --host=arm-linux-gnueabihf --prefix=$(pwd)/build --without-p11-kit

配置完成

编译

make -j4

编译成功

安装

make install


网站公告

今日签到

点亮在社区的每一天
去签到