OpenHarmony开发者论坛

标题: 在Windows的wsl服务中编译OpenHarmony源码 [打印本页]

作者: wanjie1259    时间: 2024-8-27 20:30
标题: 在Windows的wsl服务中编译OpenHarmony源码
[md]## 在Windows的wsl服务中编译OpenHarmony源码:

1、进入微软商店下载Ubuntu20.04.4;

2、进入设置可选功能打开与虚拟化相关的选项,安装后需要重启;

3、进入Ubuntu命令行设置账户和密码;

4、安装编译OpenHarmony必要的库:

```
sudo apt update &&  sudo apt-get install   kmod jfsutils reiserfsprogs xfsprogs squashfs-tools pcmciautils quota ppp libtinfo-dev libtinfo5 libncurses5-dev libncursesw5 libstdc++6 gcc-arm-none-eabi vim ssh locales gcc-arm-linux-gnueabi libc6-dev-i386 lib32ncurses-dev x11proto-core-dev libx11-dev lib32z1-dev x11proto-core-dev libx11-dev lib32z1-dev ccache libgl1-mesa-dev libxml2-utils xsltproc unzip m4 bc gnutls-bin python3.8 python3-pip ruby genext2fs device-tree-compiler make libffi-dev e2fsprogs pkg-config perl openssl libssl-dev libelf-dev libdwarf-dev u-boot-tools mtd-utils cpio doxygen liblz4-tool openjdk-8-jre gcc g++ texinfo dosfstools mtools default-jre default-jdk libncurses5 apt-utils wget scons python3.8-distutils tar rsync git-core libxml2-dev lib32z-dev grsync xxd libglib2.0-dev libpixman-1-dev  -y
```

安装repo

参考OH官方文档

设置git

```sudo
git config --global user.name "yourname"
git config --global user.email "your-email-address"
git config --global credential.helper store
```

git添加密钥

```
ssh-keygen -t rsa -C ""
```

5、将Ubuntu shell环境设置为bash

```
ls -l /bin/sh sudo dpkg-reconfigure dash        //选择否 ls -l /bin/sh                        //再次查看
```

6、安装[DevEco Device Tool 3.0 Release](https://gitee.com/link?target=ht ... cn%2Fide%23download) Linux;

```
unzip devicetool-linux-tool-3.0.0.401.zip chmod a+x devicetool-linux-tool-3.0.0.401.sh sudo ./devicetool-linux-tool-3.0.0.401.sh     //看到成功字样
```

7.源码获取;

一般是使用发行版或者使用供应商提供的代码。

8、工具的获取安装

```
bash build/prebuilts\_download.sh       //源码根路径执行
```

9、编译

```
./build.sh --product-name rk3568 --ccache      //全量编译,首次编译时间较长,我电脑编译3个多小时 //或者使用以下命令进行单模块编译 ./build.sh --product-name rk3568 -T applications/sample/wanjie/bin:wanjie\_bin --ccache
```

10、更换软件源

```
sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak sudo vim /etc/apt/sources.list    //删除原有内容,添加下面的清华源 sudo apt update

deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal main restricted universe multiverse # deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal main restricted universe multiverse deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-updates main restricted universe multiverse # deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-updates main restricted universe multiverse deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-backports main restricted universe multiverse # deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-backports main restricted universe multiverse deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-security main restricted universe multiverse # deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-security main restricted universe multiverse
```
[/md]




欢迎光临 OpenHarmony开发者论坛 (https://forums.openharmony.cn/) Powered by Discuz! X3.5