WiFi IoT 编译samgr模块

MrMrLi
发布于 2020-10-31 18:40
浏览
1收藏

 

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",终于编译成功了。

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

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模块-鸿蒙开发者社区

 

分类
标签
已于2020-10-31 18:49:56修改
1
收藏 1
回复
举报
2条回复
按时间正序
/
按时间倒序
wx5ff0943baebcf
wx5ff0943baebcf

例程引起kernel panic,绝了

回复
2021-1-19 19:09:56
liangkz_梁开祝
liangkz_梁开祝

刚好我也开始研究这一个组件了

回复
2021-4-26 14:13:33
回复
    相关推荐