【问题标题】:QGIS cannot find headers fileQGIS找不到头文件
【发布时间】:2018-02-20 13:53:09
【问题描述】:

我正在尝试使用 Qt 5.9.1

创建自定义 QGIS 桌面应用程序

我已经下载了 OSGeo4W (x64) 地理空间软件集和 Github C++ QGIS samples 但我在编译时遇到了错误:

Cannot open include file: 'qgsmapcanvas.h': No such file or directory

其实以上头文件都不在OSGeo4W文件夹下:

#include <qgsapplication.h>
#include <qgsproviderregistry.h>
#include <qgssinglesymbolrenderer.h>
#include <qgsmaplayerregistry.h>
#include <qgsrasterlayer.h>
#include <qgsmapcanvas.h>

但是..它们不应该在 dll 库中(例如 qgis_core、qgis_gui ...)吗?

无论如何,这是我的 *.pro 文件:

TEMPLATE = app
TARGET = qgis_example4
QT = sql network svg gui core xml
LANGUAGE= C++

INCLUDEPATH +=  "C:\\OSGeo4W64\\include"

LIBS += -L"C:\\OSGeo4W64\\apps\\qgis\\bin" -lqgis_core -lqgis_gui -lgdal_i -lgeos_c

DEFINES+=CORE_EXPORT=__declspec(dllexport)
DEFINES+=GUI_EXPORT=__declspec(dllexport)

CONFIG += qt gui exceptions stl warn_on debug thread

RESOURCES += resources.qrc

FORMS += mainwindowbase.ui

HEADERS = mainwindow.h

SOURCES = main.cpp \
              mainwindow.cpp

PS:stackiverflow 上有一个similar question,但我重复了一遍,因为给出的答案没有给出解决方案

【问题讨论】:

    标签: c++ qt qgis osgeo


    【解决方案1】:

    已解决:可以在项目的“qgis-dev”分支中找到所需的头文件。

    OSGeo4W:对于由于某种原因无法使用 OSGeo4W 或只是喜欢它的用户,还有来自 OSGeo4W 的 qgis-dev 每周快照standalone installer

    安装后你可以在以下位置找到标题:

    C:/Program Files/QGIS 2.99/apps/qgis-dev/include
    

    这是我的 .pro 文件

    TEMPLATE = app
    TARGET = qgis_example4
    QT = sql network svg gui core xml
    LANGUAGE= C++
    
    
    INCLUDEPATH += "C:/Program Files/QGIS 2.99/include"
    INCLUDEPATH += "C:/Program Files/QGIS 2.99/apps/qgis-dev/include"
    
    LIBS += -L"C:/Program Files/QGIS 2.99/apps/qgis-dev/bin" -lqgis_core -lqgis_gui
    
    DEFINES+=CORE_EXPORT=__declspec(dllexport)
    DEFINES+=GUI_EXPORT=__declspec(dllexport)
    
    CONFIG += qt gui exceptions stl warn_on debug thread
    
    RESOURCES += resources.qrc
    
    FORMS += mainwindowbase.ui
    
    HEADERS = mainwindow.h
    
    SOURCES = main.cpp \
              mainwindow.cpp
    

    虽然文件现在存在,但我仍然无法运行 QGIS samples。也许我会转向其他示例,或者我会做我的自定义基本应用程序。

    【讨论】:

      猜你喜欢
      • 2012-08-27
      • 2015-05-17
      • 1970-01-01
      • 2016-03-31
      • 2021-02-02
      • 2015-04-28
      • 2016-01-01
      • 2014-06-13
      相关资源
      最近更新 更多