WiFi IoT 编译samgr模块
头像 Tiechui.Wang 2020-11-02 10:17:00    发布
3770 浏览 28 点赞 22 收藏

WiFi IoT 源码里是有以下几个示例的,demolink/iothardware/samgr,前两个可以正常编译运行,但第三个即samgr时却遇到了问题。

使用的源码是从这里下载的:https://repo.huaweicloud.com/harmonyos/os/1.0/code-1.0.tar.gz

1. 第一处错误就是关于SAMGR_GetInstance()的。

后搜索发现此问题已经解决了,https://gitee.com/openharmony/applications_sample_wifi_iot/pulls/2。鸿蒙系统在gitee上开源,已经提PR修复了此问题。但在官网上下载的源码压缩包并没有同步更新,于是就按此文档介绍的添加了头文件。

WiFi IoT 编译samgr模块-鸿蒙开发者社区


../../applications/sample/wifi-iot/app/samgr/bootstrap_example.c: In function 'FEATURE_OnInitialize':
../../applications/sample/wifi-iot/app/samgr/bootstrap_example.c:75:96: error: implicit declaration of function 'SAMGR_GetProcessTime'; did you mean 'SAMGR_GetInstance'? [-Werror=implicit-function-declaration]
            osThreadGetId(), g_initIndex++, parent->GetName(parent), feature->GetName(feature), SAMGR_GetProcessTime());
                                                                                                ^~~~~~~~~~~~~~~~~~~~
                                                                                                SAMGR_GetInstance
cc1: all warnings being treated as errors
[5/205] cross compiler obj/foundation/communication/services/softbus_lite/discovery/coap/source/json_payload.o
[6/205] cross compiler obj/base/hiviewdfx/frameworks/hilog_lite/mini/hiview_output_log.o
ninja: build stopped: subcommand failed.
you can check build log in /home/client/Documents/code-1.0/out/wifiiot/build.log
/home/client/Documents/program/ninja/ninja -w dupbuild=warn -C /home/client/Documents/code-1.0/out/wifiiot failed, return code is 1


2. 按文档添加头文件后发现还有问题,如下,漏掉了bootstrap_example.c里添加头文件,于是添加了#include "time_adapter.h"。


../../applications/sample/wifi-iot/app/samgr/bootstrap_example.c: In function 'FEATURE_OnInitialize':
../../applications/sample/wifi-iot/app/samgr/bootstrap_example.c:75:96: error: implicit declaration of function 'SAMGR_GetProcessTime'; did you mean 'SAMGR_GetInstance'? [-Werror=implicit-function-declaration]
            osThreadGetId(), g_initIndex++, parent->GetName(parent), feature->GetName(feature), SAMGR_GetProcessTime());
                                                                                                ^~~~~~~~~~~~~~~~~~~~
                                                                                                SAMGR_GetInstance
cc1: all warnings being treated as errors
[6/205] cross compiler obj/foundation/communication/services/softbus_lite/discovery/coap/source/json_payload.o
[7/205] cross compiler obj/base/hiviewdfx/frameworks/hilog_lite/mini/hiview_output_log.o
ninja: build stopped: subcommand failed.
you can check build log in /home/client/Documents/code-1.0/out/wifiiot/build.log
/home/client/Documents/program/ninja/ninja -w dupbuild=warn -C /home/client/Documents/code-1.0/out/wifiiot failed, return code is 1

3. 头文件都添加好后却又出现了另一个问题,如下,fatal error: unity.h: No such file or directory

在vscode里搜索unity.h发现有两处,一处位于cJson内部,另一处在third_pard/unity目录下,还发现了其他地方引用方式,于是在/applications/sample/wifi-iot/app/samgr/BUILD.gn里添加了"//third_party/unity/src",终于编译成功了。


In file included from ../../applications/sample/wifi-iot/app/samgr/broadcast_example.c:22:0:
../../test/xts/tools/hctest/include/hctest.h:22:10: fatal error: unity.h: No such file or directory
 #include "unity.h"
          ^~~~~~~~~
compilation terminated.
[5/205] cross compiler obj/applications/sample/wifi-iot/app/samgr/bootstrap_example.o
[6/205] cross compiler obj/foundation/communication/services/softbus_lite/discovery/coap/source/json_payload.o
[7/205] cross compiler obj/base/hiviewdfx/frameworks/hilog_lite/mini/hiview_output_log.o
ninja: build stopped: subcommand failed.
you can check build log in /home/client/Documents/code-1.0/out/wifiiot/build.log
/home/client/Documents/program/ninja/ninja -w dupbuild=warn -C /home/client/Documents/code-1.0/out/wifiiot failed, return code is 1


4. 下面看一下都修改了哪些文件

需求注意的是下面贴出的图片仅是applications/sample/wifi-iot/app目录的修改,在foundation/distributedschedule/services/samgr_lite/samgr/source/BUILD.gn文件也有修改。

WiFi IoT 编译samgr模块-鸿蒙开发者社区

WiFi IoT 编译samgr模块-鸿蒙开发者社区

WiFi IoT 编译samgr模块-鸿蒙开发者社区

WiFi IoT 编译samgr模块-鸿蒙开发者社区


©本站发布的所有内容,包括但不限于文字、图片、音频、视频、图表、标志、标识、广告、商标、商号、域名、软件、程序等,除特别标明外,均来源于网络或用户投稿,版权归原作者或原出处所有。我们致力于保护原作者版权,若涉及版权问题,请及时联系我们进行处理。
分类
其它
头像

Tiechui.Wang

我还没有写个人简介......

1091

帖子

0

提问

893

粉丝

关注
热门推荐
地址:北京市朝阳区北三环东路三元桥曙光西里甲1号第三置业A座1508室 商务内容合作QQ:2291221 电话:13391790444或(010)62178877
版权所有:电脑商情信息服务集团 北京赢邦策略咨询有限责任公司
声明:本媒体部分图片、文章来源于网络,版权归原作者所有,我司致力于保护作者版权,如有侵权,请与我司联系删除
京ICP备:2022009079号-2
京公网安备:11010502051901号
ICP证:京B2-20230255