更多内容请访问:51CTO与华为官方共建鸿蒙技术社区51cto.comOpenHarmony3.1Release发布后,各个群里讨论热烈,想亲身体验一下,于是拿出被快玩弃用的“HiSparkAI相机”(主要是因为其中的两个触摸屏坏了,手上留了一个,会闪,再吐槽一下这个触摸屏,希望大鱼改进)。因为之前已经搭建了可以编译OpenHarmony3.0的Ubuntu20.04虚拟机环境,下面就以此为准。1.代码下载我指的是Gitee上的OpenHarmony3.1Release,通过repo+ssh。ssh方式比https方式更稳定。下载命令如下:repoinit-ugit@gitee.com:openharmony/manifest.git-brefs/tags/OpenHarmony-v3.1-Release--no-repo-verifyreposync-crepoforall-c'gitlfspull'./build/prebuilts_download.sh2.代码编译阅读Gitee上的OpenHarmony文档目前支持三种编译方式,有误请指正。IDE编译方式,即使用DevEcoDeviceTool使用hb编译方式build.sh编译方式这里我使用第三种build.sh编译方式进入源码根目录执行下面的命令./build.sh--product-nameHi3516DV300Hi3516DV300编译的电脑我用了8年了,所以比较慢。晚上睡觉前下了编译命令,然后第二天就收获了一个error,编译到还剩3000个文件左右就报错了。关键报错信息如下[OHOSERROR][442/3337]CCmingw_x86_64/obj/third_party/bounds_checking_function/src/libsec_static/memcpy_s.o[OHOSERROR]FAILED:mingw_x86_64/obj/third_party/bounds_checking_function/src/libcpy_static/me[OHOS错误]/usr/bin/ccache../../prebuilts/mingw-w64/ohos/linux-x86_64/clang-mingw/bin/clang-MMD-MFmingw_x86_64/obj/third_party/bounds_checking_function/src/libsec_static/memcpy_s.o.d-DV8_DEPRECATION_WARNINGS-D_FILE_OFFSET_BITS=64-D_LARGEFILE_SOURCE-D_LARGEFILE64_SOURCE-D__STDC_CONSTANT_MACROS-D__STDC_FORMAT_MACROS-D_FORTIFY_SOURCE=2-DCOMPONENT_BUILD-DNDEBUG-DNVALGRIND-DDYNAMIC_ANNOTATIONS_ENABLED=0-Imingw_x86_64/override/third_party-I../..-Imingw_x86_64/gen-I../../third_party/bounds_checking_function/include-D_INC_STRING_S-D_INC_WCHAR_S-D_SECIMP=//-D_STDIO_S_DEFINED-D_INC_STDIO_S-D_INC_STDLIB_S-D_INC_MEMORY_S-fno-strict-aliasing--param=ssp-buffer-size=4-fno-stack-protector-Wno-builtin-macro-redefined-D__DATE__=-D__TIME__=-D__TIMESTAMP__=-funwind-tables-fcolor-diagnostics-fmerge-all-constants-Xclang-mllvm-Xclang-instcombine-lower-dbg-declare=0-no-canonical-prefixes-targetx86_64-pc-windows-gnu-rtlib=compiler-rt-stdlib=libc++-lunwind-lpthread-Qunused-arguments-fuse-ld=lld-D__CUSTOM_SECURITY_LIBRARY-Wall-Werror-Wextra-Wimplicit-fallthrough-Wthread-safety-Wno-missing-field-initializers-Wno-unused-parameter-Wno-error=c99-designator-Wno-error=anon-enum-enum-conversion-Wno-error=implicit-fallthrough-Wno-error=sizeof-array-div-Wno-error=reorder-init-list-Wno-error=range-loop-construct-Wno-error=deprecated-copy-Wno-error=implicit-int-float-conversion-Wno-error=不一致-dllimport-Wno-error=未知警告选项-Wno-error=abstract-final-class-Wno-error=sign-compare-Wno-c++11-narrowing-Wno-unneeded-internal-declaration-Wno-error=c99-designator-Wno-error=anon-enum-enum-conversion-Wno-error=implicit-fallth粗糙-Wno-error=sizeof-array-div-Wno-error=reorder-init-list-Wno-error=range-loop-construct-Wno-error=deprecated-copy-Wno-error=implicit-int-float-转换-Wno-error=inconsistent-dllimport-Wno-error=unknown-warning-option-Wno-error=abstract-final-class-Wno-error=sign-compare-Wno-error=int-in-bool-context-Wno-error=xor-used-as-pow-Wno-error=return-stack-address-Wno-error=dangling-gsl-Wno-undefined-var-template-Wno-nonportable-include-path-Wno-user-定义警告-Wno-unused-lambda-capture-Wno-null-pointer-arithmetic-Wno-enum-compare-switch-O2-fno-ident-fdata-sections-ffunction-sections-fomit-frame-pointer-g2-fno-common-Wheader-hygiene-Wstring-conversion-Wtautological-overlap-compare-c../../third_party/bounds_checking_function/src/memcpy_s.c-omingw_x86_64/obj/third_party/bounds_checking_function/src/libsec_static/memcpy_s.o[OHOS错误]../../prebuilts/mingw-w64/ohos/linux-x86_64/clang-mingw/bin/clang:错误而eloadingsharedlibraries:libtinfo.so.5:cannotopensharedobjectfile:Nosuchfileordirectory查看缺少libtinfo.so.5的原因,最后通过安装libncurses5解决。遇到同样问题的朋友可以试试sudoapt-getinstalllibncurses5copy经过N个小时的编译终于编译成功,生成的镜像在out\hi3516dv300\packages\phone\images目录下网上看,这里我主要是想提醒您OpenHarmony3.1相对于OpenHarmony3.0在分区配置上有所调整。具体区别如下。为避免未知配置问题导致无法启动OpenHarmony3.0的Hi3516DV300-emmc.xml文件:
