rk3568 OpenHarmony 3.2 Release 编译(踩坑记)-从镜像站点获取源码包编译失败

系统使用LinuxMint-20.3

源码从镜像站点获取:
全量代码(标准、轻量和小型系统) 3.2 Release 21.8 GB

不是通过repo方式获取的,下载后源码压缩包名称code-v3.2-Release.tar.gz
解压后路径root/data/harmony/release_code/2023-040-09/OpenHarmony-v3.2-Release/OpenHarmony,
这个是压缩包里包含的路径,不是我加上去的。

解压源码后在源码目录执行:
bash build/prebuilts_download.sh

执行编译:
./build.sh --product-name rk3568 --ccache

出现如下错误:

[OHOS ERROR] ../../foundation/multimedia/histreamer/engine/plugin/core/plugin_register.cpp:314:5: error: use of undeclared identifier 'RegisterPluginStatic'
[OHOS ERROR]     RegisterPluginStatic(std::make_shared(registerData));
[OHOS ERROR]     ^
[OHOS ERROR] ../../foundation/multimedia/histreamer/engine/plugin/core/plugin_register.cpp:357:5: error: use of undeclared identifier 'UnregisterPluginStatic'
[OHOS ERROR]     UnregisterPluginStatic();
[OHOS ERROR]     ^
[OHOS ERROR] 2 errors generated.

经分析是因为’RegisterPluginStatic’和’UnregisterPluginStatic’没有定义。
查看foundation/multimedia/histreamer/engine/plugin/core/plugin_register.cpp源码,包含头文件all_plugin_static.h,但是该头文件没有生成,
all_plugin_static.h头文件是python脚本foundation/multimedia/histreamer/engine/plugin/plugins/plugin_config.py生成的,但不知道什么原因,该
脚本好像没有执行,导致头文件没有生成。

自己手动生成all_plugin_static.h文件,并放到foundation/multimedia/histreamer/engine/plugin/core/目录下,继续编译,
出现如下错误:

[OHOS ERROR] [14310/15425] SOLINK resourceschedule/work_scheduler/libworkschedulerextensionability_napi.z.so
[OHOS ERROR] FAILED: resourceschedule/work_scheduler/libworkschedulerextensionability_napi.z.so lib.unstripped/resourceschedule/work_scheduler/libworkschedulerextensionability_napi.z.so 
[OHOS ERROR] /usr/bin/env "../../build/toolchain/gcc_solink_wrapper.py" --readelf="../../prebuilts/clang/ohos/linux-x86_64/llvm/bin/llvm-readobj" --nm="../../prebuilts/clang/ohos/linux-x86_64/llvm/bin/llvm-nm" --strip=../../prebuilts/clang/ohos/linux-x86_64/llvm/bin/llvm-strip  --sofile="./lib.unstripped/resourceschedule/work_scheduler/libworkschedulerextensionability_napi.z.so"  --output="resourceschedule/work_scheduler/libworkschedulerextensionability_napi.z.so" --mini-debug -- ../../prebuilts/clang/ohos/linux-x86_64/llvm/bin/clang++ -shared -Wl,--version-script=/home/loongson/openharmony/root/data/harmony/release_code/2023-04-09/OpenHarmony-v3.2-Release/OpenHarmony/build/templates/cxx/napi.versionscript -Wl,--pack-dyn-relocs=android+relr -Wl,--fatal-warnings -Wl,--build-id=md5 -fPIC -Wl,-z,noexecstack -Wl,-z,now -Wl,-z,relro -Wl,-z,defs -Wl,--as-needed -fuse-ld=lld -Wl,--icf=all -Wl,--color-diagnostics -Wl,--no-undefined -Wl,--exclude-libs=libunwind_llvm.a -Wl,--exclude-libs=libc++_static.a -Wl,--exclude-libs=libvpx_assembly_arm.a --target=arm-linux-ohos -Werror -Wl,--warn-shared-textrel -Wl,-O2 -Wl,--gc-sections -Wl,--gdb-index --sysroot=obj/third_party/musl -nostdlib -Lobj/third_party/musl/usr/lib/arm-linux-ohos -L../../prebuilts/clang/ohos/linux-x86_64/llvm/lib/clang/12.0.1/lib/arm-linux-ohos -Wl,--warn-shared-textrel -o "./lib.unstripped/resourceschedule/work_scheduler/libworkschedulerextensionability_napi.z.so" @"resourceschedule/work_scheduler/libworkschedulerextensionability_napi.z.so.rsp" -Wl,-soname="libworkschedulerextensionability_napi.z.so"
[OHOS ERROR] ld.lld: error: obj/foundation/resourceschedule/work_scheduler/interfaces/kits/js/napi/work_scheduler_extension/work_scheduler_extension_ability.o: unknown file type
[OHOS ERROR] clang-12: error: linker command failed with exit code 1 (use -v to see invocation)

实在无解,怀疑是源码压缩包解压后的路径不是打包路径,怀疑要完整的按照压缩包解压的路径存放源码,即源码路径/root/data/harmony/release_code/2023-040-09/OpenHarmony-v3.2-Release/OpenHarmony/
由于编译时间比较长,以上疑点就没有验证了,且需要/root目录,这个估计要root权限。

于是使用repo方式下载源码,执行:
repo init -u https://gitee.com/openharmony/manifest -b OpenHarmony-3.2-Release --no-repo-verify
repo sync -c
repo forall -c ‘git lfs pull’

编译源码
bash build/prebuilts_download.sh
./build.sh --product-name rk3568 --ccache

编译成功,编译过程丝般顺滑,并没有出现以上错误。

所以为了避免踩坑,建议不要用从镜像站点获取源码包的方式来下载源码,希望openharmony的工程师验证下。

你可能感兴趣的:(harmonyos,华为)