NixOS 在使用鸿蒙 Command Line Tools 时的依赖问题
·
Command Line Tools 下载中心
https://developer.huawei.com/consumer/cn/download/command-line-tools-for-hmos
通常是一个 zip 包,解压后执行 bin/Emulator 会返回大致这样的结果,缺少相关的依赖。
command-line-tools/emulator/Emulator: error while loading shared libraries: libdrm.so.2: cannot open shared object file: No such file or directory
在 Emulator(跳转网页) 的文档中,有这样的说明。
当前仅支持Ubuntu 18.04及以上的Linux系统,使用前需要安装相关的依赖,以Ubuntu 18.04操作系统为例,执行命令:
apt install -y libatomic1 libpulse0 libegl1 libgbm1 libgl1 libpng16-16 libfontconfig1 libfreetype6 libxcb-icccm4 libxcb-image0 libxcb-keysyms1 libxcb-randr0 libxcb-render-util0 libxcb-shape0 libxcb-xinerama0 libxcb-xkb1 libsm6 libice6 libxkbcommon-x11-0 libxkbcommon0 libglib2.0-0
于是需要在 nixpkgs 中找到提供相关依赖的包。经过一番搜索后,在 configuration.nix 中添加
programs.nix-ld.enable = true;
programs.nix-ld.libraries = with pkgs; [
libgbm
libglvnd
libdrm
libpulseaudio
mesa
libpng
fontconfig
freetype
libxcb
libxcb-util
libSM
libICE
libxkbcommon
glib
stdenv.cc.cc.lib
];
如此,再 sudo nixos-rebuild switch 构建后,应当可以正常执行 Command Line Tools 的相关命令。

更多推荐




所有评论(0)