自学内容网 自学内容网

2024年2月23日 - mis

export LD_LIBRARY_PATH-${TOOL CHAIN}/lib64:$LD LIBRARY PATH
export CC=${GCC COMPILER}-gCC
export CXX=${GCC_COMPILER}-g++`
  1. export LD_LIBRARY_PATH=${TOOLCHAIN}/lib64:$LD_LIBRARY_PATH

    这条命令更新了环境变量LD_LIBRARY_PATH,它告诉动态链接器(runtime linker)在哪些目录中查找共享库(.so文件)。${TOOLCHAIN}/lib64是添加的新路径,而$LD_LIBRARY_PATH是现有的路径集合。通过这种方式,当运行一个程序时,如果需要加载不在系统默认库路径内的动态库,就会首先在这个新的路径中查找。export关键字确保这个变量不仅在当前Shell会话中可用,而且也会影响从此Shell启动的任何子进程。

  2. export CC=${GCC_COMPILER}-gcc

    这里设置了环境变量CC,它通常被编译系统(如Makefile)用来指定C编译器的位置。${GCC_COMPILER}-gcc指定了一个特定的GCC编译器路径,例如,如果${GCC_COMPILER}是一个指向GCC交叉编译器的路径,那么CC就指向了那个特定版本的gcc编译器。设置CC变量后,后续的编译命令将使用这个指定的编译器进行编译工作。

  3. export CXX=${GCC_COMPILER}-g++

    这条命令应当也导出CXX环境变量,与CC类似,只是这里的CXX通常用于指定C++编译器,即g++。设置CXX后,C++源代码的编译将会使用指定的g++编译器。


​ 在移动设备(特别是智能手机)的上下文中,AP(Application Processor)指的是应用处理器,它主要负责运行操作系统(如Android)、应用程序以及其他非通讯相关的功能。AP通常拥有高性能的CPU和GPU,用于处理图形、UI渲染、多媒体播放、游戏以及其他用户可见的功能。

BP(Baseband Processor)或称基带处理器,它专注于处理无线通信相关的任务,包括电话呼叫、短信服务、蜂窝网络连接(如2G、3G、4G、5G)等。BP上运行的是专门针对无线通信优化的实时操作系统,并且执行射频信号处理、编码解码、调制解调等功能。

在某些情况下,如果尝试修改与AP或BP相关的资源(例如共享内存区域或特定的硬件寄存器)时遇到问题,可能是由于对应的处理器(AP或BP)正在使用这些资源。例如,如果不能成功导出或更改一个环境变量,且该变量涉及到AP侧的内核资源,可能是因为该资源当前正被AP侧的某个进程占用;同样地,如果试图更改与BP相关的设置而无法做到,则可能是BP侧(modem)已经占据了该资源。在这种表述中,“kernel等”指的是与AP关联的操作系统内核及相关的系统资源,“modem”则是指BP的射频通信模块及其控制软件。


GCCClang编译器警告转错误选项示例

  1. 将警告视为错误的一般选项
  • -Werror:将所有警告视为错误,停止编译。
  • -Werror=warning-type:将特定类型的警告视为错误,例如:
    • -Werror=uninitialized:未初始化的变量使用。
    • -Werror=unused-variable:未使用的变量。
    • -Werror=conversion:类型转换可能造成的精度损失。
    • -Werror=sign-conversion:符号与无符号整数间的转换。
  1. 其他强化编译时检查的选项
  • -pedantic:遵循ISO C/C++标准,并报告所有不符合标准的警告。
  • -Wall:开启大多数基本警告。
  • -Wextra:开启-Wall之外的一些额外警告。
  • -Weverything(Clang专属):开启几乎所有警告。
  • -Wpedantic:在符合标准模式下报告所有非标准的构造。
  1. 特定警告类别
  • -Wunused:一系列关于未使用的资源的警告,包括:
    • -Wunused-variable
    • -Wunused-function
    • -Wunused-parameter
    • -Wunused-result
  • -Wconversion:数据类型转换的警告。
  • -Wsign-conversion:符号和无符号整数转换警告。
  • -Wfloat-equal:浮点数比较警告。
  1. 静态分析相关选项
  • -Wnull-dereference:可能的空指针解引用警告。

  • -Waddress:地址相关的警告。

  • -Warray-bounds:数组边界检查警告。

  • -Wformat:格式化字符串相关警告。

  • GCC官方文档

  • Clang官方文档


切换到root账户,不然没有权限

安装码云(Gitee)的repo工具,可以使用它来管理多个Git仓库,可以按照以下步骤进行操作:

  1. 打开终端或命令行界面。
  2. 创建一个新的目录用于存放repo工具,并进入该目录。例如,你可以使用以下命令创建一个名为"OpenHarmony"的目录,并进入该目录:
mkdir OpenHarmony  
cd OpenHarmony
  1. 使用curl命令从码云上下载repo工具的Python脚本。执行以下命令:
sudo curl -s https://gitee.com/oschina/repo/raw/fork_flow/repo-py3 > /usr/local/bin/repo

这个命令会将repo工具的Python脚本下载到/usr/local/bin/repo路径下。如果你没有权限写入该路径,你可以将脚本下载到其他目录,并将其配置到环境变量中。

  1. repo脚本添加可执行权限。执行以下命令:
sudo chmod a+x /usr/local/bin/repo
pip3 install -i https://repo.huaweicloud.com/repository/pypi/simple requests

这将使repo脚本具有可执行权限。

  1. 验证repo工具是否安装成功。在终端中执行以下命令:
repo --version

如果安装成功,你将看到repo工具的版本信息。


错误信息:

root@youyeetoo1:/home/youyeetoo1/OpenHarmony# pip3 install -i https://repo.huaweicloud.com/repository/pypi/simple requests Looking in indexes: https://repo.huaweicloud.com/repository/pypi/simple Requirement already satisfied: requests in /usr/lib/python3/dist-packages (2.22.0) root@youyeetoo1:/home/youyeetoo1/OpenHarmony# git --version git version 2.25.1 root@youyeetoo1:/home/youyeetoo1/OpenHarmony# repo init -u https://gitee.com/youyeetoo/yy3568-openharmony -b master Downloading Repo source from https://gitee.com/oschina/repo.git remote: Enumerating objects: 9008, done. remote: Total 9008 (delta 0), reused 0 (delta 0), pack-reused 9008 Receiving objects: 100% (9008/9008), 3.23 MiB | 1.07 MiB/s, done. Resolving deltas: 100% (6387/6387), done. repo: warning: verification of repo code has been disabled; repo will not be able to verify the integrity of itself. Downloading manifest from https://gitee.com/youyeetoo/yy3568-openharmony remote: Enumerating objects: 18, done. remote: Counting objects: 100% (18/18), done. remote: Compressing objects: 100% (16/16), done. remote: Total 18 (delta 0), reused 0 (delta 0), pack-reused 0 Traceback (most recent call last): File “/home/youyeetoo1/OpenHarmony/.repo/repo/main.py”, line 628, in _Main(sys.argv[1:]) File “/home/youyeetoo1/OpenHarmony/.repo/repo/main.py”, line 602, in _Main result = run() File “/home/youyeetoo1/OpenHarmony/.repo/repo/main.py”, line 595, in run = lambda: repo._Run(name, gopts, argv) or 0 File “/home/youyeetoo1/OpenHarmony/.repo/repo/main.py”, line 264, in _Run result = cmd.Execute(copts, cargs) File “/home/youyeetoo1/OpenHarmony/.repo/repo/subcmds/init.py”, line 531, in Execute self._ConfigureUser(opt) File “/home/youyeetoo1/OpenHarmony/.repo/repo/subcmds/init.py”, line 390, in _ConfigureUser name = self._Prompt(‘Your Name’, mp.UserName) File “/home/youyeetoo1/OpenHarmony/.repo/repo/project.py”, line 1030, in UserName self._LoadUserIdentity() File “/home/youyeetoo1/OpenHarmony/.repo/repo/project.py”, line 1043, in _LoadUserIdentity u = self.bare_git.var(‘GIT_COMMITTER_IDENT’) File “/home/youyeetoo1/OpenHarmony/.repo/repo/project.py”, line 3585, in runner (self._project.name, name, p.stderr)) error.GitError: manifests var: *** Please tell me who you are. Run git config --global user.email “you@example.com” git config --global user.name “Your Name” to set your account’s default identity. Omit --global to set the identity only in this repository. fatal: unable to auto-detect email address (got ‘root@youyeetoo1.(none)’) root@youyeetoo1:/home/youyeetoo1/OpenHarmony#

如果在执行repo init时,Git无法自动检测到电子邮件地址。需要设置全局的用户名和电子邮件地址。

  1. 设置全局用户名:
git config --global user.name "Your Name"

Your Name替换为您的名字。

  1. 设置全局电子邮件地址:
git config --global user.email "you@example.com"

you@example.com替换为实际电子邮件地址。


错误消息

[OHOS ERROR] [51/20609] CC obj/drivers/peripheral/audio/supportlibs/alsa_adapter/src/hdi_audio_render/alsa_lib_render.o [OHOS ERROR] FAILED: obj/drivers/peripheral/audio/supportlibs/alsa_adapter/src/hdi_audio_render/alsa_lib_render.o [OHOS ERROR] /usr/bin/ccache …/…/prebuilts/clang/ohos/linux-x86_64/llvm/bin/clang -MMD -MF obj/drivers/peripheral/audio/supportlibs/alsa_adapter/src/hdi_audio_render/alsa_lib_render.o.d -DAUDIO_HDF_LOG -DV8_DEPRECATION_WARNINGS -D_GNU_SOURCE -DHAVE_SYS_UIO_H -D__MUSL__ -D_LIBCPP_HAS_MUSL_LIBC -D__BUILD_LINUX_WITH_CLANG -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D_FORTIFY_SOURCE=2 -DCOMPONENT_BUILD -D__GNU_SOURCE=1 -DCHROMIUM_CXX_TWEAK_INLINES -D__MUSL__ -D_LIBCPP_HAS_MUSL_LIBC -D__BUILD_LINUX_WITH_CLANG -DNDEBUG -DNVALGRIND -DDYNAMIC_ANNOTATIONS_ENABLED=0 -D__OHOS_USER__ -D__OHOS_STANDARD_SYS__ -I…/…/drivers/peripheral/audio/hdi_service/passthrough/include -I…/…/drivers/peripheral/audio/supportlibs/interfaces/include -I…/…/third_party/bounds_checking_function/include -I…/…/device/hisilicon/hispark_taurus/sdk_linux/huawei_proprietary/include -I…/…/drivers/hdf_core/adapter/uhdf2/shared/include -I…/…/third_party/cJSON -I…/…/third_party/alsa-lib/include -I…/…/drivers/peripheral/audio/supportlibs/alsa_adapter/include -Iobj/third_party/musl/usr/include/arm-linux-ohos -Ioverride/third_party -I…/… -Igen -I…/…/commonlibrary/c_utils/base/include -I…/…/third_party/bounds_checking_function/include -I…/…/commonlibrary/c_utils/base/include -I…/…/drivers/hdf_core/framework/include -I…/…/drivers/hdf_core/framework/include/core -I…/…/drivers/hdf_core/framework/include/osal -I…/…/drivers/hdf_core/framework/include/utils -I…/…/drivers/hdf_core/framework/utils/include -I…/…/drivers/hdf_core/framework/core/adapter/syscall/include -I…/…/drivers/hdf_core/framework/core/adapter/vnode/include -I…/…/drivers/hdf_core/framework/core/shared/include -I…/…/drivers/hdf_core/framework/include/core -I…/…/drivers/hdf_core/adapter/uhdf2/osal/include -I…/…/drivers/hdf_core/adapter/uhdf2/utils/include -I…/…/drivers/hdf_core/adapter/uhdf2/include/hdi -I…/…/drivers/hdf_core/adapter/uhdf2/osal/include -I…/…/drivers/hdf_core/adapter/uhdf2/ipc/include -I…/…/drivers/hdf_core/framework/include/utils -Igen/drivers/interface -Igen/drivers/interface/audio -I…/…/base/hiviewdfx/hilog/interfaces/native/innerkits/include -fno-strict-aliasing --param=ssp-buffer-size=4 -fstack-protector-strong -Wno-builtin-macro-redefined -D__DATE__= -D__TIME__= -D__TIMESTAMP__= -funwind-tables -fPIC -fcolor-diagnostics -fmerge-all-constants -Xclang -mllvm -Xclang -instcombine-lower-dbg-declare=0 -no-canonical-prefixes -ffunction-sections -fno-short-enums --target=arm-linux-ohos -march=armv7-a -mfloat-abi=softfp -mtune=generic-armv7-a -mfpu=neon -mthumb -Wall -Werror -Wextra -Wimplicit-fallthrough -Wthread-safety -Wno-missing-field-initializers -Wno-unused-parameter -Wno-c++11-narrowing -Wno-unneeded-internal-declaration -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=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-defined-warnings -Wno-unused-lambda-capture -Wno-null-pointer-arithmetic -Wno-enum-compare-switch -O2 -fno-ident -fdata-sections -ffunction-sections -fomit-frame-pointer -gdwarf-3 -g2 -ggnu-pubnames -fno-common -Wheader-hygiene -Wstring-conversion -Wtautological-overlap-compare -ftrivial-auto-var-init=zero -enable-trivial-auto-var-init-zero-knowing-it-will-be-removed-from-clang --sysroot=obj/third_party/musl -c …/…/drivers/peripheral/audio/supportlibs/alsa_adapter/src/alsa_lib_render.c -o obj/drivers/peripheral/audio/supportlibs/alsa_adapter/src/hdi_audio_render/alsa_lib_render.o [OHOS ERROR] …/…/drivers/peripheral/audio/supportlibs/alsa_adapter/src/alsa_lib_render.c:191:27: error: unused variable ‘cardIns’ [-Werror,-Wunused-variable] [OHOS ERROR] struct AudioCardInfo *cardIns = NULL; [OHOS ERROR] ^ [OHOS ERROR] 1 error generated. [OHOS ERROR] [52/20609] CC obj/drivers/peripheral/audio/supportlibs/alsa_adapter/src/hdi_audio_interface_lib_render/alsa_lib_render.o [OHOS ERROR] FAILED: obj/drivers/peripheral/audio/supportlibs/alsa_adapter/src/hdi_audio_interface_lib_render/alsa_lib_render.o [OHOS ERROR] /usr/bin/ccache …/…/prebuilts/clang/ohos/linux-x86_64/llvm/bin/clang -MMD -MF obj/drivers/peripheral/audio/supportlibs/alsa_adapter/src/hdi_audio_interface_lib_render/alsa_lib_render.o.d -DAUDIO_HDF_LOG -DV8_DEPRECATION_WARNINGS -D_GNU_SOURCE -DHAVE_SYS_UIO_H -D__MUSL__ -D_LIBCPP_HAS_MUSL_LIBC -D__BUILD_LINUX_WITH_CLANG -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D_FORTIFY_SOURCE=2 -DCOMPONENT_BUILD -D__GNU_SOURCE=1 -DCHROMIUM_CXX_TWEAK_INLINES -D__MUSL__ -D_LIBCPP_HAS_MUSL_LIBC -D__BUILD_LINUX_WITH_CLANG -DNDEBUG -DNVALGRIND -DDYNAMIC_ANNOTATIONS_ENABLED=0 -D__OHOS_USER__ -D__OHOS_STANDARD_SYS__ -I…/…/drivers/peripheral/audio/hal/hdi_passthrough/include -I…/…/drivers/peripheral/audio/interfaces/include -I…/…/drivers/peripheral/audio/supportlibs/interfaces/include -I…/…/third_party/bounds_checking_function/include -I…/…/device/hisilicon/hispark_taurus/sdk_linux/huawei_proprietary/include -I…/…/drivers/peripheral/audio/supportlibs/alsa_adapter/include -I…/…/third_party/alsa-lib/include -I…/…/third_party/cJSON -Iobj/third_party/musl/usr/include/arm-linux-ohos -Ioverride/third_party -I…/… -Igen -I…/…/commonlibrary/c_utils/base/include -I…/…/third_party/bounds_checking_function/include -I…/…/commonlibrary/c_utils/base/include -I…/…/drivers/hdf_core/framework/include -I…/…/drivers/hdf_core/framework/include/core -I…/…/drivers/hdf_core/framework/include/osal -I…/…/drivers/hdf_core/framework/include/utils -I…/…/drivers/hdf_core/framework/utils/include -I…/…/drivers/hdf_core/framework/core/adapter/syscall/include -I…/…/drivers/hdf_core/framework/core/adapter/vnode/include -I…/…/drivers/hdf_core/framework/core/shared/include -I…/…/drivers/hdf_core/framework/include/core -I…/…/drivers/hdf_core/adapter/uhdf2/osal/include -I…/…/drivers/hdf_core/adapter/uhdf2/utils/include -I…/…/base/hiviewdfx/hilog/interfaces/native/innerkits/include -fno-strict-aliasing --param=ssp-buffer-size=4 -fstack-protector-strong -Wno-builtin-macro-redefined -D__DATE__= -D__TIME__= -D__TIMESTAMP__= -funwind-tables -fPIC -fcolor-diagnostics -fmerge-all-constants -Xclang -mllvm -Xclang -instcombine-lower-dbg-declare=0 -no-canonical-prefixes -ffunction-sections -fno-short-enums --target=arm-linux-ohos -march=armv7-a -mfloat-abi=softfp -mtune=generic-armv7-a -mfpu=neon -mthumb -Wall -Werror -Wextra -Wimplicit-fallthrough -Wthread-safety -Wno-missing-field-initializers -Wno-unused-parameter -Wno-c++11-narrowing -Wno-unneeded-internal-declaration -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=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-defined-warnings -Wno-unused-lambda-capture -Wno-null-pointer-arithmetic -Wno-enum-compare-switch -O2 -fno-ident -fdata-sections -ffunction-sections -fomit-frame-pointer -gdwarf-3 -g2 -ggnu-pubnames -fno-common -Wheader-hygiene -Wstring-conversion -Wtautological-overlap-compare -ftrivial-auto-var-init=zero -enable-trivial-auto-var-init-zero-knowing-it-will-be-removed-from-clang --sysroot=obj/third_party/musl -c …/…/drivers/peripheral/audio/supportlibs/alsa_adapter/src/alsa_lib_render.c -o obj/drivers/peripheral/audio/supportlibs/alsa_adapter/src/hdi_audio_interface_lib_render/alsa_lib_render.o [OHOS ERROR] …/…/drivers/peripheral/audio/supportlibs/alsa_adapter/src/alsa_lib_render.c:191:27: error: unused variable ‘cardIns’ [-Werror,-Wunused-variable] [OHOS ERROR] struct AudioCardInfo *cardIns = NULL; [OHOS ERROR] ^ [OHOS ERROR] 1 error generated.

../../drivers/peripheral/audio/supportlibs/alsa_adapter/src/alsa_lib_render.c的第191行,声明了一个名为cardIns的变量,但该变量未被使用,并且由于启用了-Werror选项(将警告视为错误),导致编译失败。

错误详情:

[OHOS ERROR] ../../drivers/peripheral/audio/supportlibs/alsa_adapter/src/alsa_lib_render.c:191:27: error: unused variable 'cardIns' [-Werror,-Wunused-variable]
[OHOS ERROR]     struct AudioCardInfo *cardIns = NULL;

注释掉cardIns这个变量


系统发出警告提示:当前使用的pip版本为20.2.3,但最新可用的pip版本为23.0.1。通过运行以下命令来升级pip版本:

/home/youyeetoo1/OpenHarmony/prebuilts/python/linux-x86/3.9.2/bin/python3.9 -m pip install --upgrade pip

原文地址:https://blog.csdn.net/weixin_51604843/article/details/136261867

免责声明:本站文章内容转载自网络资源,如本站内容侵犯了原著者的合法权益,可联系本站删除。更多内容请关注自学内容网(zxcms.com)!