Qt相关:Qt版本?Qt模块?Qt配置?Project ERROR: Unknown module(s) in QT: positioning-private location-pri? 2017-12-27 22:55:45

最近入坑QGroundControl,其readme要求Qt版本必须是Qt 5.9.2。那么怎么知道自己的Qt版本呢?

敲入:qmake -v

输出:QMake version 3.0
Using Qt version 5.6.2 in /home/jason/anaconda3/lib

哦,好吧,需要到https://www.qt.io/download-qt-for-application-development安装一个,选择open source。可以直接下载,也可以点击小字“View All Downloads”

我选择直接下载,下载的文件是qt-unified-linux-x64-3.0.2-online.run。这个文件是不能直接运行的,必须用sudo或者chmod +x之后再执行。

一路next,安装之后就可以了,那么这个qt安装到哪里去了呢?/opt/QT/5.9.2这里。

打开Qt creator,打开工程qgroundcontrol中的QGCLocationPlugin,会发现有这么一句:

QT  += location-private positioning-private network
 这个是配置信息,表示用到了Qt的这些个module。是的,Qt还有很多module,介绍在http://doc.qt.io/qt-5/qtmodules.html。 

这个location和position都是Qt中module,分别用于:

Qt Location     Displays map, navigation, and place content in a QML application.
Qt Positioning     Provides access to position, satellite and area monitoring classes.
都是显示地图用到的。

如果你直接在Qt creator中构建项目,就会报错,无法找到QtLocation/private/qgeotiledmapreply_p.h等,或者是Project ERROR: Unknown module(s) in QT: positioning-private location-private。为什么,是因为我们没有安装这些模块吗?到opt/QT/5.9.2/gcc_64/include中看一下,发现有啊。那肯定是什么地方没有配置好。

再将鼠标放到其他#include,发现QTimer等其他模块还是指到/usr/include/x86_64-linux-gnu/qt5/QtLocation中,这就确定了我们在安装Qt5.9.2以后没有在qt creator中配置正确。

配置过程:

“工具”->"选项"->Qt Versions->"添加",选择/opt/Qt/5.9.2/gcc_64/bin/qmake。然后再选择“构建套件”标签,点击“手动设置”->"桌面(默认)",选择Qt版本:Qt5.9.2(gcc_64)就可以了。

这时候可能还会报找不到QtLocation/private/qgeotiledmapreply_p.h等错误,这时可以到opt/QT/5.9.2/gcc_64/include中看一下,它们可能在5.9.2的子目录下,把它们手动sudo rm到正确的位置就可以了。

Building on: linux-g++ (x86_64, CPU features: mmx sse sse2) Building for: linux-aarch64-gnu-g++ (arm64, CPU features: neon) Target compiler: gcc 6.3.1 Configuration: cross_compile use_gold_linker compile_examples enable_new_dtags largefile neon precompile_header shared rpath release c++11 c++14 concurrent dbus reduce_exports stl Build options: Mode ................................... release Optimize release build for size ........ no Building shared libraries .............. yes Using C standard ....................... C11 Using C++ standard ..................... C++14 Using ccache ........................... no Using gold linker ...................... yes Using new DTAGS ........................ yes Using precompiled headers .............. yes Using LTCG ............................. no Target compiler supports: NEON ................................. yes Build parts ............................ libs Qt modules and options: Qt Concurrent .......................... yes Qt D-Bus ............................... yes Qt D-Bus directly linked to libdbus .... no Qt Gui ................................. yes Qt Network ............................. yes Qt Sql ................................. yes Qt Testlib ............................. yes Qt Widgets ............................. yes Qt Xml ................................. yes Support enabled for: Using pkg-config ....................... yes udev ................................... no Using system zlib ...................... yes Qt Core: DoubleConversion ....................... yes Using system DoubleConversion ........ no GLib ................................... no iconv .................................. yes ICU .................................... no Tracing backend ........................ Logging backends: journald ............................. no syslog ............................... no slog2 ................................ no Using system PCRE2 ..................... no Qt Network: getifaddrs() ........................... yes IPv6 ifname ............................ yes libproxy ............................... no Linux AF_NETLINK ....................... yes OpenSSL ................................ yes Qt directly linked to OpenSSL ........ no OpenSSL 1.1 ............................ no DTLS ................................... yes SCTP ................................... no Use system proxies ..................... yes Qt Gui: Accessibility .......................... yes FreeType ............................... yes Using system FreeType ................ no HarfBuzz ............................... yes Using system HarfBuzz ................ no Fontconfig ............................. no Image formats: GIF .................................. yes ICO .................................. yes JPEG ................................. yes Using system libjpeg ............... yes PNG .................................. yes Using system libpng ................ no EGL .................................... no OpenVG ................................. no OpenGL: Desktop OpenGL ....................... no OpenGL ES 2.0 ........................ no OpenGL ES 3.0 ........................ no OpenGL ES 3.1 ........................ no OpenGL ES 3.2 ........................ no Vulkan ................................. no Session Management ..................... yes Features used by QPA backends: evdev .................................. yes libinput ............................... no INTEGRITY HID .......................... no mtdev .................................. no tslib .................................. no xkbcommon .............................. no X11 specific: XLib ................................. no EGL on X11 ........................... no QPA backends: DirectFB ............................... no EGLFS .................................. no LinuxFB ................................ yes VNC .................................... yes Mir client ............................. no Qt Sql: SQL item models ........................ yes Qt Widgets: GTK+ ................................... no Styles ................................. Fusion Windows Qt PrintSupport: CUPS ................................... no Qt Sql Drivers: DB2 (IBM) .............................. no InterBase .............................. no MySql .................................. no OCI (Oracle) ........................... no ODBC ................................... no PostgreSQL ............................. no SQLite2 ................................ no SQLite ................................. yes Using system provided SQLite ......... no TDS (Sybase) ........................... no Qt Testlib: Tester for item models ................. yes Qt SerialBus: Socket CAN ............................. yes Socket CAN FD .......................... yes Qt QML: QML network support .................... yes QML debugging and profiling support .... yes QML sequence object .................... yes QML list model ......................... yes QML XML http request ................... yes QML Locale ............................. yes QML delegate model ..................... yes Qt Quick: Direct3D 12 ............................ no AnimatedImage item ..................... yes Canvas item ............................ yes Support for Qt Quick Designer .......... yes Flipable item .......................... yes GridView item .......................... yes ListView item .......................... yes TableView item ......................... yes Path support ........................... yes PathView item .......................... yes Positioner items ....................... yes Repeater item .......................... yes ShaderEffect item ...................... yes Sprite item ............................ yes Qt Scxml: ECMAScript data model for QtScxml ...... yes Qt Gamepad: SDL2 ................................... no Qt 3D: Assimp ................................. yes System Assimp .......................... no Output Qt3D Job traces ................. no Output Qt3D GL traces .................. no Use SSE2 instructions .................. no Use AVX2 instructions .................. no Aspects: Render aspect ........................ yes Input aspect ......................... yes Logic aspect ......................... yes Animation aspect ..................... yes Extras aspect ........................ yes Qt 3D Renderers: OpenGL Renderer ........................ yes Qt 3D GeometryLoaders: Autodesk FBX ........................... no Qt Wayland Client ........................ no Qt Wayland Compositor .................... no Qt Bluetooth: BlueZ .................................. no BlueZ Low Energy ....................... no Linux Crypto API ....................... no WinRT Bluetooth API (desktop & UWP) .... no Qt Sensors: sensorfw ............................... no Qt Quick Controls 2: Styles ................................. Default Fusion Imagine Material Universal Qt Quick Templates 2: Hover support .......................... yes Multi-touch support .................... yes Qt Positioning: Gypsy GPS Daemon ....................... no WinRT Geolocation API .................. no Qt Location: Qt.labs.location experimental QML plugin . yes Geoservice plugins: OpenStreetMap ........................ yes HERE ................................. yes Esri ................................. yes Mapbox ............................... yes MapboxGL ............................. no Itemsoverlay ......................... yes QtXmlPatterns: XML schema support ..................... yes Qt Multimedia: ALSA ................................... no GStreamer 1.0 .......................... no GStreamer 0.10 ......................... no Video for Linux ........................ yes OpenAL ................................. no PulseAudio ............................. no Resource Policy (libresourceqt5) ....... no Windows Audio Services ................. no DirectShow ............................. no Windows Media Foundation ............... no Qt Tools: QDoc ................................... no Qt WebEngine: Embedded build ......................... yes Pepper Plugins ......................... no Printing and PDF ....................... no Proprietary Codecs ..................... no Spellchecker ........................... yes Native Spellchecker .................... no WebRTC ................................. no Use System Ninja ....................... no Geolocation ............................ yes WebChannel support ..................... yes Use v8 snapshot ........................ yes Kerberos Authentication ................ no Building v8 snapshot supported ......... yes Use ALSA ............................... no Use PulseAudio ......................... no Optional system libraries used: re2 .................................. no icu .................................. no libwebp, libwebpmux and libwebpdemux . no opus ................................. no ffmpeg ............................... no libvpx ............................... no snappy ............................... no glib ................................. no zlib ................................. yes minizip .............................. no libevent ............................. no jsoncpp .............................. no protobuf ............................. no libxml2 and libxslt .................. no lcms2 ................................ no png .................................. no JPEG ................................. no harfbuzz ............................. no freetype ............................. no x11 .................................. no Required system libraries: fontconfig ........................... no dbus ................................. no nss .................................. no khr .................................. no glibc ................................ yes Required system libraries for qpa-xcb: libdrm ............................... no xcomposite ........................... no xcursor .............................. no xi ................................... no xrandr ............................... no xtst ................................. no Note: Also available for Linux: linux-clang linux-icc 本系列的上一篇带大家初识了一下QtLocation这个模块。如果只是需要显示/浏览地图和一些简单的交互,那么QtLocation提供的QML类型已经足够满足需求了。先来看看QtLocation提供了哪些QML类型(罗列的Qt5.6版的类型,Qt现在更新得很快,已经Qt12了;Qt... 文章目录前言一、为什么要使用QtLocation二、参考资料1.QGC:[http://qgroundcontrol.com/](http://qgroundcontrol.com/) 源码:[https://github.com/mavlink/qgroundcontrol](https://github.com/mavlink/qgroundcontrol)2.github 上发现的高德地图插件:[https://github.com/SindenDev/amap](https://github... 这种错误是因为找不到charts的modules,通常出现在移植的时候。 这一般是因为在安装QT的时候没有安装Qt Charts,因为Qt Charts默认不安装 已经安装过QT的,可以运行MaintenanceTool添加组件,也可以卸载后重新安装。 安装时勾选Qt Charts,安装Charts组件 安装过charts组件后就可以成功构建啦! 根据Qt官方的解释(在Qt的帮助文档里也可以看到),在5.6版本以及之后的版本Qt已经移除了webkitwidgets模块,并用一个新的模块webenginewidgets替代之。 Qt5.5.1是最后一个支持webkitwidgets的版本QT       += core gui webenginewidgets... 这种错误是因为找不到对应的modules,通常出现在移植的时候,或者是因为在安装QT的时候没有安装对应的模块, 已经安装过QT的,可以运行MaintenanceTool添加组件,也可以卸载后重新安装。 MaintenanceTool.exe工具一般位于QT的安装目录中,例如我的是在路径D:\Qt\Qt5.6.0 在MaintenanceTool中,选择“添加或移除组件”点了下一步,提示“要继续此操作,至少需要一个有效且已启用的储存库”,只能点设置手动配置了(因为默认的储存库不能用,所以会提示)。因此 问题描述:         我在一台计算机的Qt 5.9.7写了用到饼状图的程序,是能正常运行的代码。         将这个程序拷贝到另一台计算机的Qt 5.7.0里运行,出现编译错误:error: Unknown module(s) in Qt:Charts。 可能的原因: