Windows10 + Qt5.11.0 + QGC3.2.0 + VS2015

簡介

本文介紹 (QGroundControl, QGC) 的安裝配置, QGroundControl 是一個地面站監控軟件, 支持 GPU 渲染與加速, 爲無人機提供全飛行控制和任務規劃, 提供開源代碼, 支持Linux, Windows, Android, Mac 等多種平臺.

QGroundControl provides full flight control and mission planning for any MAVLink enabled drone. It provides configuration for ArduPilot or PX4 Pro powered vehicles. Its primary goal is ease of use for first time and professional users. All the code is open-source source, so you can contribute and evolve it as you want.

代碼基於 Qt 開發框架編寫, 下面介紹其安裝及配置.

來自網絡

環境簡介

環境說明

根據 QGC 官網文檔 , 配置環境如下, 注意新版QGC3.4僅支持Qt 5.11.0:

  • OSX: OSX 10.7 or higher, 64 bit, clang compiler
  • Ubuntu: 64 bit, gcc compiler
  • Windows: Vista or higher, 32 bit, Visual Studio 2015 compiler
  • iOS: 8.0 and higher
  • Android: Jelly Bean (4.1) and higher. Standard QGC is built against ndk version 19.
  • Qt version: 5.11.0 (only)

資源下載

下載鏈接如下:

注意: 根據 QGC 官網文檔 ,QGC 源碼中不包含子模塊源碼,:

Github source-code zip files cannot be used because these do not contain the appropriate submodule source code. You must use git!

下載時需要使用 git 命令遞歸克隆, 這樣可以同時克隆子模塊源碼, 直接點擊下載 zip 源碼包不會包含子模塊源碼, 不遞歸克隆, 構建QGC工程源碼時會出現 MAVLink folder does not exist … submodule 錯誤, 參見問題解決的 MAVLink folder does not exist submodule 部分.

Git是一個版本控制系統, 可以到 這裏 下載. GitHub是個git遠程倉庫, 用於存儲代碼包.下載安裝好git後, 打開 Git Bash 命令終端, 輸入QGC源碼下載命令:

1. Clone the repo (or your fork):
git clone --recursive https://github.com/mavlink/qgroundcontrol.git
2. Enter into the directory
cd qgroundcontrol
3. Update submodules (do this each time you pull new source code):
git submodule update

如下圖所示, 其中 recursive 代表遞歸, 代碼比較大(437 MB (459,235,320 字節)), 不使用遞歸命令, 或者直接下載比較小(394 MB (413,795,660 字節)), 需耐心等待(PS: 可以在等待的過程安裝Qt VS等):
git QGC log

代碼日誌記錄如下:

$ git clone --recursive https://github.com/mavlink/qgroundcontrol.git
Cloning into 'qgroundcontrol'...
remote: Enumerating objects: 233, done.
remote: Counting objects: 100% (233/233), done.
remote: Compressing objects: 100% (162/162), done.
Receiving objects: 100% (107431/107431), 324.15 MiB | 20.00 KiB/s, done.
remote: Total 107431 (delta 127), reused 95 (delta 68), pack-reused 107198
Resolving deltas: 100% (81657/81657), done.
Checking out files: 100% (2783/2783), done.
Submodule 'libs/mavlink/include/mavlink/v2.0' (https://github.com/mavlink/c_library_v2.git) registered for path 'libs/mavlink/include/mavlink/v2.0'
Submodule 'src/GPS/Drivers' (https://github.com/PX4/GpsDrivers.git) registered for path 'src/GPS/Drivers'
Cloning into 'F:/zhiliu/github/qgroundcontrol/libs/mavlink/include/mavlink/v2.0'...
remote: Enumerating objects: 174, done.
remote: Counting objects: 100% (174/174), done.
remote: Compressing objects: 100% (140/140), done.
remote: Total 14066 (delta 138), reused 65 (delta 34), pack-reused 13892
Receiving objects: 100% (14066/14066), 6.47 MiB | 129.00 KiB/s, done.
Resolving deltas: 100% (12854/12854), done.
Cloning into 'F:/zhiliu/github/qgroundcontrol/src/GPS/Drivers'...
remote: Enumerating objects: 56, done.
remote: Counting objects: 100% (56/56), done.
remote: Compressing objects: 100% (26/26), done.
remote: Total 455 (delta 35), reused 48 (delta 30), pack-reused 399
Receiving objects: 100% (455/455), 170.63 KiB | 276.00 KiB/s, done.
Resolving deltas: 100% (329/329), done.
Submodule path 'libs/mavlink/include/mavlink/v2.0': checked out '32dcf73bb24516dc0d52119e624fda8987a03f62'
Submodule path 'src/GPS/Drivers': checked out '8828fb9ad3a2cad568feac2b46de7d6d3af32ca8'

由於 qgroundcontrol 源碼比較大, 經常下不下來, git clone 命令不支持斷點續傳, 故可以使用如下命令下載, 當下載中斷時, 再次執行 git fetch 那句命令即可. 打開 Git Bash 終端, 進入你想存放源碼的目錄(提示: 進入磁盤cd 盤符 , 如 cd E:), 然後執行:

$ mkdir qgroundcontrol
$ cd qgroundcontrol
$ git init
$ git fetch --recurse-submodules https://github.com/mavlink/qgroundcontrol.git
remote: Enumerating objects: 215, done.
remote: Counting objects: 100% (215/215), done.
remote: Compressing objects: 100% (149/149), done.
Receiving objects: 100% (98818/98818), 255.77 MiB | 25.00 KiB/s, done.
remote: Total 98818 (delta 123), reused 84 (delta 66), pack-reused 98603
Resolving deltas: 100% (75211/75211), done.
From https://github.com/mavlink/qgroundcontrol
 * branch                HEAD       -> FETCH_HEAD
$ git pull https://github.com/mavlink/qgroundcontrol.git

也可以單獨下載, 然後放到對應目錄即可:

  • c_library_v2: 放到 libs/mavlink/include/mavlink/v2.0 目錄下;
  • GpsDrivers: 放到 src/GPS/Drivers 目錄下.

子模塊在QGroundControl源碼中的位置

安裝與配置

VS 安裝與配置

VS 安裝

VS安裝略過, 記得勾選C++編譯器等即可.

一個例子

下面介紹一個例子: 文件 --> 新建 --> 項目 --> win32項目, 輸入項目名稱, 如 HelloWorld, 確定, 菜單欄 調試 --> 開始調試 , 若提示"無法打開 源 文件 "vcruntime.h" 請參照後面問題解決部分.

下圖爲程序運行結果:
VS GUI工程示例

Qt & Qt Creator 安裝

安裝

雙擊安裝程序, 選擇安裝路徑, 安裝即可, 注意:

  • 勾選 Qt Creator : 這裏自帶的版本爲 Qt Creator 4.6.1;
  • 勾選 MSVC 2015 32 組件;
  • 如果想使用 MinGW也請勾選.

早期版本中, 以上文件爲單獨的安裝包, 如qt-opensource-windows-x86-msvc2015-5.7.1.exe, 現在做成了組件.

Qt 組件

UWP即Windows 10中的Universal Windows Platform簡稱。即Windows通用應用平臺,在Windows 10 Mobile/Surface(Windows平板電腦)/PC/Xbox/HoloLens等平臺上運行,uwp不同於傳統pc上的exe應用,也跟只適用於手機端的app有本質區別。它並不是爲某一個終端而設計,而是可以在所有windows10設備上運行。

本文在安裝時選擇安裝了 MinGW, MSVC 2015 32 組件, 在 工具–>選項–>構建和運行–>構建套件(Kit) 中可以看到自動檢測到的編譯器(MSVC的和MinGW的), 在構建項目時選擇一個即可.

需要注意的是, 若需調試, 使用MSVC編譯器還需安裝CDB調試工具, 關於CDB調試, 參考下文 “Qt 中 使用VC部分”.

VS中配置Qt

Qt插件安裝

對於VS中Qt插件的安裝, 早期版本是下載單獨的文件安裝, VS2015中安裝Qt插件的方法爲: VS2015 --> 工具 --> 擴展和更新 彈出的界面選擇 聯機 在右側輸入 Qt 搜索, 點擊下載安裝, 安裝後重啓VS生效, 如下圖所示:

在VS中安裝Qt插件

如圖所示, VS2015中有兩個主要Qt插件: Qt Visual Studio Tools, QtPackage, 功能大同小異. 安裝好後, 分別對應: Qt VS Tools, QT5.

Qt插件配置

安裝完插件需要在插件中配置Qt路徑, 菜單欄選擇 Qt VS Tools --> Qt Options 或者 QT5 --> Qt Options,在彈出的路徑中, 點擊 Add 按鈕, 選擇相應Qt版本所在主目錄(如E:\devtools\Qt\Qt5.11.0\5.11.0\msvc2015). 若不進行配置, 在新建工程時會提示

VS中提示沒有Qt

一個例子

VS中菜單欄: 文件–>新建 --> 項目, 在彈出的窗口中選擇 模版-->Visual C++ --> Qt --> Qt GUI Application , 輸入項目名新建項目, 運行彈出如下窗口

VS中使用QT示例

注意: 若出現問題, 請移步下文 “問題與解決” 部分的 “VS使用問題” 小節.

Qt 中配置VC

Qt中使用CDB調試

關於調試, 下載Windows SDk 安裝包, 在 windows downloads 裏搜索即可, 裏面有Debug Tools. 如 Windows 10 SDK: 含調試器等下載, 點擊 DOWNLOAD THE .ISO 下載iso文件安裝;
安裝時選擇調試工具

安裝 好後 Qt中便可以自動檢測到VC++調試器, 如下圖所示:

Qt自動檢測到的CDB調試器

注意: 若出現問題, 請移步下文 “問題與解決” 部分的 “QT使用問題” 小節.

一個例子

文件–>新建文件或項目–>項目–>Application–>Qt Widgets Application 新建QtGUI工程,

QT程序構建編譯運行或調試, 及QT測試例子窗口

至此爲止, Qt中可以正常使用VC編譯器調試與運行, VS中也可以運行QT工程. 下面介紹QGC的安裝.

QGroundControl 編譯與安裝

打開下載好的含submodules的QGC源碼工程. 刪掉 qgroundcontrol.pro.user 文件, 構建編譯,輸出如下日誌:

Running Windows Runtime device detection.
No winrtrunner.exe found.
Project MESSAGE: Qt version 5.11.0
Project MESSAGE: Windows build
Project MESSAGE: QGroundControl Development master:bcabdc26a 2018-10-24 15:55:25 -0700
Project MESSAGE: Release flavor
Project MESSAGE: Using Default QtLocation headers
Project MESSAGE: Using MAVLink dialect 'ardupilotmega'.
Project MESSAGE: Skipping support for Zeroconf (unsupported platform)
Project MESSAGE: Skipping support for Airmap (unsupported platform)
Project MESSAGE: Skipping support for video streaming (GStreamer libraries not installed)
Project MESSAGE: Installation instructions here: https://github.com/mavlink/qgroundcontrol/blob/master/src/VideoStreaming/README.md
Project ERROR: Unknown module(s) in QT: charts
Cannot read E:/devtools/Qt/qgroundcontrol/user_config.pri: No such file or directory
Cannot read /.qmake.stash: No such file or directory
Project MESSAGE: Qt version 5.11.0
Project MESSAGE: Windows build
Project MESSAGE: QGroundControl Development master:bcabdc26a 2018-10-24 15:55:25 -0700
Project MESSAGE: Debug flavor
Cannot read E:/pkg-config_wrapper.sh.bat: No such file or directory
Project MESSAGE: Using MAVLink dialect 'ardupilotmega'.
Project MESSAGE: Skipping support for Zeroconf (unsupported platform)
Project MESSAGE: Skipping support for Airmap (unsupported platform)
Project MESSAGE: Skipping support for video streaming (GStreamer libraries not installed)
Project MESSAGE: Installation instructions here: https://github.com/mavlink/qgroundcontrol/blob/master/src/VideoStreaming/README.md
Cannot read E:/moc/mocinclude.opt: No such file or directory
Project ERROR: Unknown module(s) in QT: charts
Cannot read E:/devtools/Qt/qgroundcontrol/user_config.pri: No such file or directory

構建Debug出現錯誤, 改成Release成功!

成功編譯運行結果

問題與解決

VS安裝使用問題

Project ERROR: Cannot run compiler ‘cl’. Output:

關於 CL.exe
添加VC編譯器路徑到 PATH環境變量 (電腦 --> 屬性 --> 高級系統設置 --> 環境變量 -->系統變量 ) , 如: C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin , 在該文件夾中可以看到 cl.exe .

無法打開 源 文件 “vcruntime.h”

無法打開 源 文件 "vcruntime.h"	HelloWorld	c:\Program Files (x86)\Windows Kits\10\Include\10.0.10240.0\ucrt\corecrt.h	10	

無法打開 源 文件錯誤截圖

右擊項目 --> 屬性 打開項目屬性頁, 按下圖添加包含目錄路徑:

包含目錄添加

按下圖添加包含目錄路徑:

附加庫目錄添加

QT安裝使用問題

C1083: Cannot open include file: ‘type_traits’: No such file or directory

\msvc2015_64\include\QtCore\qglobal.h:45: error: C1083: Cannot open include file: 'type_traits': No such file or directory

然而, 上述文件可以在 C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include 中找到, 故添加環境變量來解決此問題, 系統 --> 高級系統設置 --> 環境變量, 在系統變量中新增/添加如下環境變量:

  • INCLUDE: C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include;%INCLUDE%
  • LIB: C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\lib\;%LIB%

添加上述環境變量後即可成功運行QT示例程序.

error: LNK1104: cannot open file ‘msvcprtd.lib’

:-1: error: LNK1104: cannot open file 'msvcprtd.lib'

如果在上一步中, LIB 的路徑有誤, 或者你添加的環境變量名稱爲 LIBPATH, 即:

  • LIBPATH: C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\lib\;%LIBPATH%

就會出現此問題, 通過在QT中單擊 項目 可以看到環境變量中有 LIB, LIBPATH 兩個,事先添加的LIBPATH, 沒有添加LIB, 運行提示上述錯誤, 添加LIB環境變量後錯誤消失. 當然, 你也可以在QT中添加環境變量, 如下圖:

QT中的環境變量設置

QGC

MAVLink folder does not exist submodule

如果你構建QGC出現如下錯誤,說明你下載的QGC源碼中不含 submodule 模塊:

Project MESSAGE: Using MAVLink dialect 'ardupilotmega'.
Project ERROR: MAVLink folder does not exist at 'libs/mavlink/include/mavlink/v2.0'! Run 'git submodule init && git submodule update' on the command line.

根據提示, 打開 Git Bash 終端, 運行命令: git submodule init && git submodule update 等待下載完成, 重新構建QGC工程即可.
在這裏插入圖片描述

Unsupported Windows toolchain, only Visual Studio 2015 is supported

QGC僅支持 VS2015, 然而裝的就是VS2015, 再次檢查發現是構建套件問題, 刪除源碼目錄中的 qgroundcontrol.pro.user 文件, 重新打開工程, 選擇構建套件構建.

: error: Unsupported Windows toolchain, only Visual Studio 2015 is supported

Project ERROR: Unknown module(s) in QT: charts

需要在安裝QT時選擇安裝 Qt Charts.

參考

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章