【HarmonyOS HiSpark IPC试用】开发Hi3518第一个示例程序Say Hello to HarmonyOS - HarmonyOS技术社区 - 电子技术论坛 - 广受欢迎的专业电子论坛
分享 收藏 返回

fannifu 关注 私信

【HarmonyOS HiSpark IPC试用】开发Hi3518第一个示例程序Say Hello to HarmonyOS

本帖最后由 fannifu 于 2022-3-15 23:05 编辑

开发者需要在Linux服务器上下载并解压一套源代码,获取Hi3518源码(下载链接https://gitee.com/openharmony/docs/blob/master/get-code/%E6%BA%90%E7%A0%81%E8%8E%B7%E5%8F%96.md)。更多源码获取方式,请见源码获取。

下载是用windows10, 放在e盘
  1. cd ~
  2. cd  /mnt/e


解压源码
vscode 安装wsl:ubuntu插件可以打开 wsl:ubuntu文件, 这点用win10非常方便
引用:
#include "los_sample.h"
int main(int argc, char **argv)
    printf("n************************************************n");
    printf("Hi I'm Lojam, Hello OHOS!nr");
    printf("Copyright @sunshine Silicon nr ");
    printf("n************************************************nn");
    LOS_Sample(g_num);        // 鸿蒙系统特有的我也不知道是什么意思, 同一个示例目录里 调用los_samle.c里的LOS_Sample函数
    return 0;
}



los_samle.c内容

  1. #include

int g_num = 81;
void LOS_Sample(int param)
{
    printf("This is a sample: Param = %dn", param);
}



看看这个目录的Makefile内容
  1. STAtiC_COMPILE = n

BIN = helloworld
BIN_ASM = $(BIN).asm
OBJEXT = .o

  • CC = ${LITEOS_COMPILER_PATH}/bin/$(CROSS_COMPILE)gcc        //这里用的是交叉编译工具gcc,而非是官方python脚本用的是clang, 直接make出错
    CPP = ${LITEOS_COMPILER_PATH}/bin/$(CROSS_COMPILE)g++
    LD = ${LITEOS_COMPILER_PATH}/bin/$(CROSS_COMPILE)ld
    OBJDUMP = ${LITEOS_COMPILER_PATH}/bin/$(CROSS_COMPILE)objdump

  • COMMON_INCLUDE = -I $(APP_DIR)/include/
    COMMON_FLAGS = -fPIE -D_XOPEN_SOURCE=700

  • CFLAGS += -fno-omit-frame-pointer -std=c99 $(COMMON_INCLUDE) $(COMMON_FLAGS)
    CXXFLAGS += $(COMMON_INCLUDE) $(COMMON_FLAGS)

  • ifeq ($(STATIC_COMPILE), y)
            LDFLAGS = --static
    else
            LDFLAGS = -pie
    endif

  • CCSRCS := $(wildcard *.c)
    CCOBJS = $(CCSRCS:.c=$(OBJEXT))
    CXXSRCS := $(wildcard *.cpp)
    CXXOBJS = $(CXXSRCS:.cpp=$(OBJEXT))

  • MUSL = musl/lib/libc.so

  • all: $(MUSL) $(BIN) $(BIN_ASM)

  • $(CCOBJS): %$(OBJEXT): %.c
            @echo "CC: [        DISCUZ_CODE_51        ]lt;"
            $(Q) $(CC) -c $(CFLAGS) [        DISCUZ_CODE_51        ]lt; -o $@

  • $(CXXOBJS): %$(OBJEXT): %.cpp
            @echo "CPP: [        DISCUZ_CODE_51        ]lt;"
            $(Q) $(CPP) -c $(CXXFLAGS) [        DISCUZ_CODE_51        ]lt; -o $@

  • $(BIN_ASM): $(BIN)
            $(Q) rm -rf $(CCOBJS) $(CXXOBJS)
            $(Q) $(OBJDUMP) -d $(BIN) > $(BIN_ASM)

  • $(MUSL):
            $(Q) rm -rf musl/
            $(Q) ./build_musl.sh &> build_musl.log

  • $(BIN): $(MUSL) $(CCOBJS) $(CXXOBJS)
    ifeq ($(STATIC_COMPILE), y)
            @echo "LD: $^"
            $(Q) $(CC) $(LDFLAGS) -o $@ $^
    else
            @echo "LD: $^"
            $(Q)mkdir -p $(APP_DIR)/lib/
            $(Q)cp -f $(APP_DIR)/src/musl/lib/libc.so $(APP_DIR)/lib/libc.so
            $(Q)$(CC) $(LDFLAGS) -o $@ $(CCOBJS) $(CXXOBJS)
    endif

  • clean:
            $(Q) rm -rf $(CCOBJS) $(CXXOBJS) $(BIN) $(BIN_ASM)
            $(Q) rm -rf musl/
            $(Q) rm -rf build_musl.log

  • install:
            $(Q) mkdir -p $(FSIMG_DIR)
            $(Q) install $(BIN) $(FSIMG_DIR)/$(BIN)



    编译
    之前Linux开发uboot、内核、文件系统、应用是分开编译的,一般只编译一次烧录,应用直接make编译出来copy到硬件环境里就可以了
    这里是所有的uboot、内核、文件系统、应用一起编译初次使用还有,后面老全部编译就很麻烦了,编译时间长,希望可以应用直接编译,然后copy到板子里,后面写应用或驱动就方便多了
    1. python build.py ipcamera_hi3518ev300 -b debug



    编译出错了,把编译日志放出来,希望能有大神帮助解决, 我找问题解决了再更新了…………OMG………………

    ……没有找到./adapt_liteos_config.sh:…………
    1. /home/fan/HarmonyOS_Code/vendor/hisi/hi35xx/middleware/source/third_party/ffmpeg
    2. ./adapt_liteos_config.sh: 4: function: not found
    3. sed: -e expression #1, char 0: no previous regular expression
    4. ./adapt_liteos_config.sh: 11: function: not found


    5. ./adapt_liteos_config.sh: 19: function: not found
    6. adapt ffmpeg for liteos
    7. ./adapt_liteos_config.sh: 29: effect_opt: not found
    8. ./adapt_liteos_config.sh: 30: effect_opt: not found
    9. ./adapt_liteos_config.sh: 31: effect_opt: not found
    10. ./adapt_liteos_config.sh: 32: effect_opt: not found
    11. ./adapt_liteos_config.sh: 33: effect_opt: not found
    12. ./adapt_liteos_config.sh: 34: effect_opt: not found
    13. ./adapt_liteos_config.sh: 35: effect_opt: not found
    14. ./adapt_liteos_config.sh: 36: effect_opt: not found
    15. ./adapt_liteos_config.sh: 37: effect_opt: not found
    16. ./adapt_liteos_config.sh: 38: effect_opt: not found
    17. ./adapt_liteos_config.sh: 39: effect_opt: not found
    18. ./adapt_liteos_config.sh: 40: effect_opt: not found
    19. ./adapt_liteos_config.sh: 41: effect_opt: not found
    20. ./adapt_liteos_config.sh: 42: effect_opt: not found
    21. ./adapt_liteos_config.sh: 43: effect_opt: not found
    22. ./adapt_liteos_config.sh: 44: effect_opt: not found
    23. ./adapt_liteos_config.sh: 45: effect_opt: not found
    24. ./adapt_liteos_config.sh: 46: effect_opt: not found
    25. ./adapt_liteos_config.sh: 48: cancel_opt: not found
    26. ./adapt_liteos_config.sh: 49: cancel_opt: not found
    27. ./adapt_liteos_config.sh: 50: cancel_opt: not found
    28. ./adapt_liteos_config.sh: 51: cancel_opt: not found
    29. ./adapt_liteos_config.sh: 52: cancel_opt: not found
    30. ./adapt_liteos_config.sh: 53: cancel_opt: not found
    31. ./adapt_liteos_config.sh: 54: cancel_opt: not found
    32. ./adapt_liteos_config.sh: 55: cancel_opt: not found

    33. ./adapt_liteos_config.sh: 56: cancel_opt: not found



    ……  1大票头文件没有, gitee下载的源码有问题……OMG…………
    1. libavdevice/alsa.c:31:10: fatal error: 'alsa/asoundlib.h' file not found
    2. #include
    3.          ^~~~~~~~~~~~~~~~~~
    4. libavdevice/alsa_dec.c:48:10: fatal error: 'alsa/asoundlib.h' file not found
    5. #include
    6.          ^~~~~~~~~~~~~~~~~~
    7. 1 error generated.
    8. In file included from libavdevice/alldevices.c:23:
    9. In file included from ./libavformat/internal.h:27:
    10. In file included from ./libavformat/avformat.h:317:
    11. In file included from ./libavcodec/avcodec.h:31:
    12. In file included from ./libavutil/samplefmt.h:24:
    13. In file included from ./libavutil/avutil.h:296:
    14. In file included from ./libavutil/common.h:491:
    15. In file included from ./libavutil/internal.h:42:
    16. ./libavutil/timer.h:37:11: fatal error: 'asm/unistd.h' file not found
    17. # include
    18.           ^~~~~~~~~~~~~~
    19. libavdevice/android_camera.c:29:10: fatal error: 'camera/NdkCameraDevice.h' file not found
    20. #include
    21.          ^~~~~~~~~~~~~~~~~~~~~~~~~~
    22. 1 error generated.
    23. make[1]: *** [ffbuild/common.mak:60: libavdevice/alsa.o] Error 1
    24. make[1]: *** Waiting for unfinished jobs....
    25. In file included from libavdevice/bktr.c:27:
    26. In file included from ./libavformat/internal.h:27:
    27. In file included from ./libavformat/avformat.h:317:
    28. In file included from ./libavcodec/avcodec.h:31:
    29. In file included from ./libavutil/samplefmt.h:24:
    30. In file included from ./libavutil/avutil.h:296:
    31. In file included from ./libavutil/common.h:491:
    32. In file included from ./libavutil/internal.h:42:
    33. ./libavutil/timer.h:37:11: fatal error: 'asm/unistd.h' file not found
    34. # include
    35.           ^~~~~~~~~~~~~~
    36. 1 error generated.
    37. make[1]: *** [ffbuild/common.mak:60: libavdevice/alldevices.o] Error 1
    38. make[1]: *** [ffbuild/common.mak:60: libavdevice/alsa_dec.o] Error 1
    39. libavdevice/alsa_enc.c:40:10: fatal error: 'alsa/asoundlib.h' file not found
    40. #include
    41.          ^~~~~~~~~~~~~~~~~~
    42. In file included from libavdevice/decklink_dec_c.c:23:
    43. In file included from ./libavformat/avformat.h:317:
    44. In file included from ./libavcodec/avcodec.h:31:
    45. In file included from ./libavutil/samplefmt.h:24:
    46. In file included from ./libavutil/avutil.h:296:
    47. In file included from ./libavutil/common.h:491:
    48. In file included from ./libavutil/internal.h:42:
    49. ./libavutil/timer.h:37:11: fatal error: 'asm/unistd.h' file not found
    50. # include
    51.           ^~~~~~~~~~~~~~
    52. 1 error generated.
    53. libavdevice/avfoundation.m:28:9: fatal error: 'AVFoundation/AVFoundation.h' file not found
    54. #import
    55.         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    56. make[1]: *** [ffbuild/common.mak:60: libavdevice/bktr.o] Error 1
    57. 1 error generated.
    58. In file included from libavdevice/avdevice.c:19:
    59. In file included from ./libavutil/avassert.h:31:
    60. In file included from ./libavutil/avutil.h:296:
    61. In file included from ./libavutil/common.h:491:
    62. In file included from ./libavutil/internal.h:42:
    63. ./libavutil/timer.h:37:11: fatal error: 'asm/unistd.h' file not found
    64. # include
    65.           ^~~~~~~~~~~~~~
    66. In file included from libavdevice/decklink_enc_c.c:22:
    67. In file included from ./libavformat/avformat.h:317:
    68. In file included from ./libavcodec/avcodec.h:31:
    69. In file included from ./libavutil/samplefmt.h:24:
    70. In file included from ./libavutil/avutil.h:296:
    71. In file included from ./libavutil/common.h:491:
    72. In file included from ./libavutil/internal.h:42:
    73. ./libavutil/timer.h:37:11: fatal error: 'asm/unistd.h' file not found
    74. # include
    75.           ^~~~~~~~~~~~~~
    76. make[1]: *** [ffbuild/common.mak:60: libavdevice/android_camera.o] Error 1
    77. 1 error generated.
    78. libavdevice/caca.c:21:10: fatal error: 'caca.h' file not found
    79. #include
    80.          ^~~~~~~~
    81. 1 error generated.
    82. 1 error generated.
    83. 1 error generated.
    84. 1 error generated.
    85. make[1]: *** [ffbuild/common.mak:60: libavdevice/decklink_dec_c.o] Error 1
    86. make[1]: *** [ffbuild/common.mak:60: libavdevice/alsa_enc.o] Error 1
    87. make[1]: *** [ffbuild/common.mak:60: libavdevice/avdevice.o] Error 1
    88. make[1]: *** [ffbuild/common.mak:66: libavdevice/avfoundation.o] Error 1
    89. make[1]: *** [ffbuild/common.mak:60: libavdevice/decklink_enc_c.o] Error 1
    90. 1 error generated.
    91. make[1]: *** [ffbuild/common.mak:60: libavdevice/caca.o] Error 1
    92. In file included from libavdevice/dshow_common.c:22:
    93. In file included from libavdevice/dshow_capture.h:27:
    94. In file included from libavdevice/avdevice.h:48:
    95. In file included from ./libavutil/log.h:25:
    96. In file included from ./libavutil/avutil.h:296:
    97. In file included from ./libavutil/common.h:491:
    98. In file included from ./libavutil/internal.h:42:
    99. ./libavutil/timer.h:37:11: fatal error: 'asm/unistd.h' file not found
    100. # include
    101.           ^~~~~~~~~~~~~~
    102. In file included from libavdevice/dshow.c:22:
    103. In file included from libavdevice/dshow_capture.h:27:
    104. In file included from libavdevice/avdevice.h:48:
    105. In file included from ./libavutil/log.h:25:
    106. In file included from ./libavutil/avutil.h:296:
    107. In file included from ./libavutil/common.h:491:
    108. In file included from ./libavutil/internal.h:42:
    109. ./libavutil/timer.h:37:11: fatal error: 'asm/unistd.h' file not found
    110. # include
    111.           ^~~~~~~~~~~~~~
    112. 1 error generated.
    113. make[1]: *** [ffbuild/common.mak:60: libavdevice/dshow_common.o] Error 1
    114. 1 error generated.
    115. make[1]: *** [ffbuild/common.mak:60: libavdevice/dshow.o] Error 1
    116. libavdevice/decklink_enc.cpp:31libavdevice/decklink_common.cpp:10::28 :fatal error10: :'DeckLinkAPI.h' file not found
    117. fatal error: 'DeckLinkAPI.h' file not found
    118. #include
    119. #include          ^~~~~~~~~~~~~~~


    120.          ^~~~~~~~~~~~~~~
    121. libavdevice/decklink_dec.cpp:33:10: fatal error: 'DeckLinkAPI.h' file not found
    122. #include
    123.          ^~~~~~~~~~~~~~~
    124. 1 error generated.
    125. 1 error generated.
    126. make[1]: *** [ffbuild/common.mak:63: libavdevice/decklink_enc.o] Error 1
    127. make[1]: *** [ffbuild/common.mak:63: libavdevice/decklink_common.o] Error 1
    128. 1 error generated.
    129. make[1]: *** [ffbuild/common.mak:63: libavdevice/decklink_dec.o] Error 1
    130. make[1]: Leaving directory '/home/fan/HarmonyOS_Code/vendor/hisi/hi35xx/middleware/source/third_party/ffmpeg/ffmpeg-y'
    131. make: *** [Makefile:41: ffmpeg-y] Error 2
    132. Traceback (most recent call last):
    133.   File "../../build/lite/build_ext_components.py", line 64, in
    134.     sys.exit(main())
    135.   File "../../build/lite/build_ext_components.py", line 58, in main
    136.     cmd_exec(args.command)
    137.   File "../../build/lite/build_ext_components.py", line 32, in cmd_exec
    138.     raise Exception("{} failed, return code is {}".format(cmd, ret_code))

    139. Exception: ['./build.sh', '/home/fan/HarmonyOS_Code/out/ipcamera_hi3518ev300', 'hi3518ev300', 'liteos_a', 'clang', '/home/fan/llvm/bin/..'] failed, return code is 2




    回帖(1)

    高久峰

    2021-6-17 17:26:06
    兄弟 乱码了  尽快修复啊。兄弟 乱码了  尽快修复啊。兄弟 乱码了  尽快修复啊。兄弟 乱码了  尽快修复啊。兄弟 乱码了  尽快修复啊。兄弟 乱码了  尽快修复啊。兄弟 乱码了  尽快修复啊。兄弟 乱码了  尽快修复啊。

    更多回帖

    我也要说两句 回帖

    相关经验

    ×

    发帖