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

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

    准备工作

请依照这篇文章搭建环境

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

下载

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

解压

tar -xf 
mkdir ./out
cd ./out 

Cmake命令

这里需要更换一下目录

cmake .. \
-DPAHO_WITH_SSL=TRUE \
-DPAHO_BUILD_DOCUMENTATION=FALSE \
-DOPENSSL_ROOT_DIR=/home/vtstar/Desktop/openharmony/ThirtyPartRestore/openssl/openssl-1.1.1a/build \
-DOPENSSL_CRYPTO_LIBRARY=/home/vtstar/Desktop/openharmony/ThirtyPartRestore/openssl/openssl-1.1.1a/build/lib/libcrypto.so \
-DOPENSSL_INCLUDE_DIR=/home/vtstar/Desktop/openharmony/ThirtyPartRestore/openssl/openssl-1.1.1a/build/include \
-DOPENSSL_SSL_LIBRARY=/home/vtstar/Desktop/openharmony/ThirtyPartRestore/openssl/openssl-1.1.1a/build/lib/libssl.so \
-DCMAKE_C_COMPILER="/home/vtstar/Desktop/openharmony/sdk/sdk_linux_5.0.0.71/native/llvm/bin/clang" \
-DCMAKE_CXX_COMPILER="/home/vtstar/Desktop/openharmony/sdk/sdk_linux_5.0.0.71/native/llvm/bin/clang++" \
-DCMAKE_LINKER="/home/vtstar/Desktop/openharmony/sdk/sdk_linux_5.0.0.71/native/llvm/bin/ld.lld" \
-DCMAKE_SYSTEM_NAME=Linux \
-DCMAKE_SYSTEM_PROCESSOR=arm \
-DCMAKE_C_FLAGS="-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 -I/home/vtstar/Desktop/openharmony/ThirtyPartRestore/openssl/openssl-1.1.1a/build/include --target=arm-linux-ohos" \
-DCMAKE_CXX_FLAGS="-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 -I/home/vtstar/Desktop/openharmony/ThirtyPartRestore/openssl/openssl-1.1.1a/build/include --target=arm-linux-ohos" \
-DCMAKE_EXE_LINKER_FLAGS="-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 -L/home/vtstar/Desktop/openharmony/ThirtyPartRestore/openssl/openssl-1.1.1a/build/lib" \
-DCMAKE_INSTALL_PREFIX=./out

编译

cd ..
make -clean
make

编译成功

安装

make install


网站公告

今日签到

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