赞
踩
ohos@ubuntu20:~/tools/OH_SDK$ cd ohos-sdk
ohos@ubuntu20:~/tools/OH_SDK/ohos-sdk$ ls
linux windows
ohos@ubuntu20:~/tools/OH_SDK/ohos-sdk$ cd linux/
ohos@ubuntu20:~/tools/OH_SDK/ohos-sdk/linux$ ls
ets-linux-x64-4.0.1.2-Canary1.zip native-linux-x64-4.0.1.2-Canary1.zip toolchains-linux-x64-4.0.1.2-Canary1.zip
js-linux-x64-4.0.1.2-Canary1.zip previewer-linux-x64-4.0.1.2-Canary1.zip
ohos@ubuntu20:~/openHarmony/openssl$ export OHOS_SDK=/home/ohos/tools/OH_SDK/ohos-sdk/linux #这里根据自己的SDK解压目录设置
ohos@ubuntu20:~/openHarmony/openssl$ export AS=${OHOS_SDK}/native/llvm/bin/llvm-as
ohos@ubuntu20:~/openHarmony/openssl$ export CC="${OHOS_SDK}/native/llvm/bin/clang --target=aarch64-linux-ohos"
ohos@ubuntu20:~/openHarmony/openssl$ export CXX="${OHOS_SDK}/native/llvm/bin/clang++ --target=aarch64-linux-ohos"
ohos@ubuntu20:~/openHarmony/openssl$ export LD=${OHOS_SDK}/native/llvm/bin/ld.lld
ohos@ubuntu20:~/openHarmony/openssl$ export STRIP=${OHOS_SDK}/native/llvm/bin/llvm-strip
ohos@ubuntu20:~/openHarmony/openssl$ export RANLIB=${OHOS_SDK}/native/llvm/bin/llvm-ranlib
ohos@ubuntu20:~/openHarmony/openssl$ export OBJDUMP=${OHOS_SDK}/native/llvm/bin/llvm-objdump
ohos@ubuntu20:~/openHarmony/openssl$ export OBJCOPY=${OHOS_SDK}/native/llvm/bin/llvm-objcopy
ohos@ubuntu20:~/openHarmony/openssl$ export NM=${OHOS_SDK}/native/llvm/bin/llvm-nm
ohos@ubuntu20:~/openHarmony/openssl$ export AR=${OHOS_SDK}/native/llvm/bin/llvm-ar
ohos@ubuntu20:~/openHarmony/openssl$ export CFLAGS="-fPIC -D__MUSL__=1"
ohos@ubuntu20:~/openHarmony/openssl$ export CXXFLAGS="-fPIC -D__MUSL__=1"
ohos@ubuntu20:~/openHarmony/openssl$ ./Configure linux-aarch64 --prefix=/home/ohos/openHarmony/openssl_install
# 在需要选择系统的时候由于configure不识别ohos,因此我们需要使用Linux aarch64等价系统和cpu架构 为了方便打包,需要指定安装目录
Configuring OpenSSL version 1.1.1t (0x1010114fL) for linux-aarch64
Using os-specific seed configuration
Creating configdata.pm
Creating Makefile
**********************************************************************
*** ***
*** OpenSSL has been successfully configured ***
*** ***
*** If you encounter a problem while building, please open an ***
*** issue on GitHub <https://github.com/openssl/openssl/issues> ***
*** and include the output from the following command: ***
*** ***
*** perl configdata.pm --dump ***
*** ***
*** (If you are new to OpenSSL, you might want to consult the ***
*** 'Troubleshooting' section in the INSTALL file first) ***
*** ***
**********************************************************************
ohos@ubuntu20:~/openHarmony/openssl$ make
/usr/bin/perl "-I." -Mconfigdata "util/dofile.pl" \
"-oMakefile" include/crypto/bn_conf.h.in > include/crypto/bn_conf.h
/usr/bin/perl "-I." -Mconfigdata "util/dofile.pl" \
"-oMakefile" include/crypto/dso_conf.h.in > include/crypto/dso_conf.h
/usr/bin/perl "-I." -Mconfigdata "util/dofile.pl" \
"-oMakefile" include/openssl/opensslconf.h.in > include/openssl/opensslconf.h
make depend && make _all
make[1]: Entering directory '/home/ohos/openHarmony/openssl'
make[1]: Leaving directory '/home/ohos/openHarmony/openssl'
make[1]: Entering directory '/home/ohos/openHarmony/openssl'
/home/ohos/tools/OH_SDK/ohos-sdk/linux/native/llvm/bin/clang -I. -Iinclude -fPIC -pthread -Wa,--noexecstack -Qunused-arguments -fPIC --target=aarch64-linux-ohos -D__MUSL__=1 -DOPENSSL_USE_NODELETE -DOPENSSL_PIC -DOPENSSL_CPUID_OBJ -DOPENSSL_BN_ASM_MONT -DSHA1_ASM -DSHA256_ASM -DSHA512_ASM -DKECCAK1600_ASM -DVPAES_ASM -DECP_NISTZ256_ASM -DPOLY1305_ASM -DOPENSSLDIR="\"/home/ohos/openHarmony/openssl_install/ssl\"" -DENGINESDIR="\"/home/ohos/openHarmony/openssl_install/lib/engines-1.1\"" -DNDEBUG -MMD -MF apps/app_rand.d.tmp -MT apps/app_rand.o -c -o apps/app_rand.o apps/app_rand.c
# 删除大量 make 日志
${LDCMD:-/home/ohos/tools/OH_SDK/ohos-sdk/linux/native/llvm/bin/clang} -pthread -Wa,--noexecstack -Qunused-arguments -fPIC --target=aarch64-linux-ohos -D__MUSL__=1 -L. \
-o test/x509aux test/x509aux.o \
test/libtestutil.a -lcrypto -ldl -pthread
/usr/bin/perl "-I." -Mconfigdata "util/dofile.pl" \
"-oMakefile" apps/CA.pl.in > "apps/CA.pl"
chmod a+x apps/CA.pl
/usr/bin/perl "-I." -Mconfigdata "util/dofile.pl" \
"-oMakefile" apps/tsget.in > "apps/tsget.pl"
chmod a+x apps/tsget.pl
/usr/bin/perl "-I." -Mconfigdata "util/dofile.pl" \
"-oMakefile" tools/c_rehash.in > "tools/c_rehash"
chmod a+x tools/c_rehash
/usr/bin/perl "-I." -Mconfigdata "util/dofile.pl" \
"-oMakefile" util/shlib_wrap.sh.in > "util/shlib_wrap.sh"
chmod a+x util/shlib_wrap.sh
make[1]: Leaving directory '/home/ohos/openHarmony/openssl'
ohos@ubuntu20:~/openHarmony/openssl$ make install
make depend && make _build_libs
make[1]: Entering directory '/home/ohos/openHarmony/openssl'
make[1]: Leaving directory '/home/ohos/openHarmony/openssl'
make[1]: Entering directory '/home/ohos/openHarmony/openssl'
make[1]: Nothing to be done for '_build_libs'.
make[1]: Leaving directory '/home/ohos/openHarmony/openssl'
created directory `/home/ohos/openHarmony/openssl_install/lib'
*** Installing runtime libraries
install libcrypto.so.1.1 -> /home/ohos/openHarmony/openssl_install/lib/libcrypto.so.1.1
install libssl.so.1.1 -> /home/ohos/openHarmony/openssl_install/lib/libssl.so.1.1
*** Installing development files
created directory `/home/ohos/openHarmony/openssl_install/include'
created directory `/home/ohos/openHarmony/openssl_install/include/openssl'
install ./include/openssl/aes.h -> /home/ohos/openHarmony/openssl_install/include/openssl/aes.h
install ./include/openssl/asn1.h -> /home/ohos/openHarmony/openssl_install/include/openssl/asn1.h
install ./include/openssl/asn1_mac.h -> /home/ohos/openHarmony/openssl_install/include/openssl/asn1_mac.h
# 删除大量 install 日志
/home/ohos/openHarmony/openssl_install/share/doc/openssl/html/man7/X25519.html
/home/ohos/openHarmony/openssl_install/share/doc/openssl/html/man7/X448.html -> /home/ohos/openHarmony/openssl_install/share/doc/openssl/html/man7/X25519.html
/home/ohos/openHarmony/openssl_install/share/doc/openssl/html/man7/x509.html
ohos@ubuntu20:~/openHarmony/openssl$
root@kw:~/d# cd poco-poco-1.12.6
root@kw:~/d/poco-poco-1.12.6# mkdir ohos64build&&cd ohos64build
root@kw:~/d/poco-poco-1.12.6/ohos64build# /root/d/ohos-sdk/linux/native/build-tools/cmake/bin/cmake -DCMAKE_TOOLCHAIN_FILE=/root/d/ohos-sdk/linux/native/build/cmake/ohos.toolchain.cmake -DOPENSSL_ROOT_DIR=/root/d/ohos-sdk/linux/native/sysroot/usr/openssl .. -L
-- The C compiler identification is Clang 15.0.4
-- The CXX compiler identification is Clang 15.0.4
-- Check for working C compiler: /root/d/ohos-sdk/linux/native/llvm/bin/clang
-- Check for working C compiler: /root/d/ohos-sdk/linux/native/llvm/bin/clang -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /root/d/ohos-sdk/linux/native/llvm/bin/clang++
-- Check for working CXX compiler: /root/d/ohos-sdk/linux/native/llvm/bin/clang++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Checking for C++14 compiler
-- Checking for C++14 compiler - available
-- Found OpenSSL: /root/d/ohos-sdk/linux/native/sysroot/usr/openssl/lib/libcrypto.so
-- Could NOT find APR (missing: APR_INCLUDE_DIR APR_LIBRARY)
-- Could NOT find APRUTIL (missing: APRUTIL_INCLUDE_DIR APRUTIL_LIBRARY)
-- Could NOT find Apache2 (missing: APACHE2_INCLUDE_DIR)
-- Could NOT find MySQL (missing: MYSQL_INCLUDE_DIR MYSQL_LIBRARY)
-- Could NOT find PostgreSQL (missing: PostgreSQL_LIBRARY PostgreSQL_INCLUDE_DIR)
-- Could NOT find ODBC (missing: ODBC_LIBRARY ODBC_INCLUDE_DIR)
-- Building without tests & samples
-- Using internal sqlite, zlib, pcre2, expat, ...
-- SQLite Support Enabled
-- MySQL Support Disabled
-- PostgreSQL Support Disabled
-- ODBC Support Disabled
-- CMake 3.16.5 successfully configured Poco using Unix Makefiles generator
-- Poco package version: 1.12.6
-- Building dynamic libraries
-- [cmake] Installation target path: /usr/local
-- [cmake] Use toolchain file: /root/d/ohos-sdk/linux/native/build/cmake/ohos.toolchain.cmake
-- [cmake] Build for OS type: OHOS
-- [cmake] Build for OS version: 1
-- [cmake] Build for CPU type: aarch64
-- [cmake] Build type: RelWithDebInfo
-- [cmake] Build with cxx flags: -O2 -g -DNDEBUG -fdata-sections -ffunction-sections -funwind-tables -fstack-protector-strong -no-canonical-prefixes -fno-addrsig -Wa,--noexecstack -Wformat -Werror=format-security -D__MUSL__
-- [cmake] Build with c flags: -O2 -g -DNDEBUG -fdata-sections -ffunction-sections -funwind-tables -fstack-protector-strong -no-canonical-prefixes -fno-addrsig -Wa,--noexecstack -Wformat -Werror=format-security -D__MUSL__
-- Building: Encodings
-- Building: XML
-- Building: JSON
-- Building: Util
-- Building: Net
-- Building: MongoDB
-- Building: Redis
-- Building: Prometheus
-- Building: JWT
-- Building: NetSSL_OpenSSL
-- Building: Crypto
-- Building: Data
-- Building: Data/SQLite
-- Building: ActiveRecord
-- Building: ActiveRecordCompiler
-- Building: Zip
-- Building: PageCompiler
-- Building: File2Page
-- Configuring done
-- Generating done
-- Build files have been written to: /root/d/poco-poco-1.12.6/ohos64build
-- Cache values
BUILD_SHARED_LIBS:BOOL=ON
CMAKE_ASM_FLAGS:STRING=
CMAKE_ASM_FLAGS_DEBUG:STRING=
CMAKE_ASM_FLAGS_RELEASE:STRING=
CMAKE_BUILD_TYPE:STRING=
CMAKE_DEBUG_POSTFIX:STRING=d
CMAKE_INSTALL_PREFIX:PATH=/usr/local
CMAKE_MINSIZEREL_POSTFIX:STRING=
CMAKE_RELEASE_POSTFIX:STRING=
CMAKE_RELWITHDEBINFO_POSTFIX:STRING=
CMAKE_TOOLCHAIN_FILE:FILEPATH=/root/d/ohos-sdk/linux/native/build/cmake/ohos.toolchain.cmake
ENABLE_ACTIVERECORD:BOOL=ON
ENABLE_ACTIVERECORD_COMPILER:BOOL=ON
ENABLE_APACHECONNECTOR:BOOL=OFF
ENABLE_CPPPARSER:BOOL=OFF
ENABLE_CRYPTO:BOOL=ON
ENABLE_DATA:BOOL=ON
ENABLE_DATA_MYSQL:BOOL=OFF
ENABLE_DATA_ODBC:BOOL=OFF
ENABLE_DATA_POSTGRESQL:BOOL=OFF
ENABLE_DATA_SQLITE:BOOL=ON
ENABLE_ENCODINGS:BOOL=ON
ENABLE_ENCODINGS_COMPILER:BOOL=OFF
ENABLE_FOUNDATION:BOOL=ON
ENABLE_JSON:BOOL=ON
ENABLE_JWT:BOOL=ON
ENABLE_MONGODB:BOOL=ON
ENABLE_NET:BOOL=ON
ENABLE_NETSSL:BOOL=ON
ENABLE_NETSSL_WIN:BOOL=OFF
ENABLE_PAGECOMPILER:BOOL=ON
ENABLE_PAGECOMPILER_FILE2PAGE:BOOL=ON
ENABLE_PDF:BOOL=OFF
ENABLE_POCODOC:BOOL=OFF
ENABLE_PROMETHEUS:BOOL=ON
ENABLE_REDIS:BOOL=ON
ENABLE_SEVENZIP:BOOL=OFF
ENABLE_TESTS:BOOL=OFF
ENABLE_UTIL:BOOL=ON
ENABLE_XML:BOOL=ON
ENABLE_ZIP:BOOL=ON
FORCE_OPENSSL:BOOL=OFF
POCO_NO_FORK_EXEC:BOOL=OFF
POCO_UNBUNDLED:BOOL=OFF
STATIC_POSTFIX:STRING=
注意:
首先,这里执行的 cmake 是 SDK 内的 cmake,不是你自己系统上原有的 cmake。包括 toolchain file 也是 SDK 内的。所以在编译 OpenSSL 库时,要将 --prefix 设置为 /ohos-sdk/linux/native/sysroot/usr
其次,cmake执行的过程中,一定要确保出现:
– Found OpenSSL: /root/d/ohos-sdk/linux/native/sysroot/usr/openssl/lib/libcrypto.so
– Building: NetSSL_OpenSSL
– Building: Crypto
ENABLE_CRYPTO:BOOL=ON
ENABLE_NETSSL:BOOL=ON
root@kw:~/d/poco-poco-1.12.6/ohos64build# make -j2
root@kw:~/d/poco-poco-1.12.6/ohos64build/lib# ls
libPocoActiveRecord.so libPocoDataSQLite.so.96 libPocoJWT.so libPocoNetSSL.so.96 libPocoXML.so
libPocoActiveRecord.so.96 libPocoEncodings.so libPocoJWT.so.96 libPocoPrometheus.so libPocoXML.so.96
libPocoCrypto.so libPocoEncodings.so.96 libPocoMongoDB.so libPocoPrometheus.so.96 libPocoZip.so
libPocoCrypto.so.96 libPocoFoundation.so libPocoMongoDB.so.96 libPocoRedis.so libPocoZip.so.96
libPocoData.so libPocoFoundation.so.96 libPocoNet.so libPocoRedis.so.96
libPocoData.so.96 libPocoJSON.so libPocoNet.so.96 libPocoUtil.so
libPocoDataSQLite.so libPocoJSON.so.96 libPocoNetSSL.so libPocoUtil.so.96
root@kw:~/d/poco-poco-1.12.6/ohos64build/lib# file libPocoCrypto.so libPocoCrypto.so.96
libPocoCrypto.so: symbolic link to libPocoCrypto.so.96
libPocoCrypto.so.96: ELF 64-bit LSB shared object, ARM aarch64, version 1 (SYSV), dynamically linked, BuildID[sha1]=e2b34d4ba732ff18d5ed2445804f706ab063b50e, with debug_info, not stripped
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。