---
# System prepended metadata

title: 遠端Debug QT程式

---

遠端Debug QT程式
===

本篇主要紀錄如何透過遠端跨平台debug QT程式。

---

環境:

1. Raspberry pi
2. 建好的Yocto image [建置範例](https://hackmd.io/WoDfPXS5QOKBoPY-qjjUcQ)
:::info
必須包含meta-qt
:::
3. Ubuntu 20.04 x64

主要架構會有一台HOST PC負責編譯QT程式，並經由SFTP部屬到Raspberry pi上執行。

[參考資料](https://embeddeduse.com/2020/06/19/qt-embedded-systems-2-build-qt-sdk-with-yocto/)

---

## HOST PC上安裝Toolchain

1. 編譯Toolchain:
```
bitbake meta-toolchain-qt5
```

:::info
local.conf 完全依照
[建置範例](https://hackmd.io/WoDfPXS5QOKBoPY-qjjUcQ)
:::

:::info
因為我之後會用到Opencv，因此在local.conf新增:
TOOLCHAIN_TARGET_TASK_append = " opencv"
將toolchain新增opencv library
:::

2. 安裝SDK:
```bash=
bash $WORKSPACE/tmp/deploy/sdk/poky-glibc-x86_64-meta-toolchain-qt5-cortexa7t2hf-neon-vfpv4-raspberrypi4-toolchain-3.3+snapshot.sh
```

:::info
$WORKSPACE表示專案所在目錄
:::

上述bash script將會把toolchain安裝在/opy/poky路徑下

3. 載入環境變數:
```bash
source /opt/poky/3.3+snapshot/environment-setup-cortexa7t2hf-neon-vfpv4-poky-linux-gnueabi
```

:::info
每次使用前都需要載入
:::

---

## HOST PC上部屬:

1. 安裝qtcreator

2. 開啟qtcreator
```bash=
qtcreator
```

3. 開起專案:

這裡我開啟qqtest.pro

![](https://i.imgur.com/KNzlqIA.png)



