Мои проекты состоят из нескольких подпроектов, один из которых включает библиотеки QGIS.QGIS с автономным приложением C++ в Qt Creator
.pro файл:
TEMPLATE = subdirs
CONFIG += ordered
SUBDIRS += \
Utils \
Maps \
GoogleMapsInterface \
Positioning \
NetworkObjects \
DataBaseManager \
SensorNetworkUI \
Это .pro файл Карт, который включает в себя Qgis библиотеки:
CONFIG += c++11
CONFIG += staticlib
TEMPLATE = lib
QT += core gui
QT += widgets
QT += xml
TARGET = maps
DEFINES += MAPS_INTERFACE
INCLUDEPATH += "C:/OSGeo4W/apps/qgis/include/"
INCLUDEPATH += "C:/OSGeo4W/include/"
win32:CONFIG(Release, Debug|Release) {
LIBS += -LC:/OSGeo4W/lib/ -lQtCore4
LIBS += -LC:/OSGeo4W/lib/ -lQtGui4
LIBS += -LC:/OSGeo4W/lib/ -lQtXml4
}
else:win32:CONFIG(Debug, Debug|Release) {
PRE_TARGETDEPS += C:/OSGeo4W/lib/QtCored4.lib
PRE_TARGETDEPS += C:/OSGeo4W/lib/QtGuid4.lib
PRE_TARGETDEPS += C:/OSGeo4W/lib/QtXmld4.lib
LIBS += -LC:/OSGeo4W/lib/ -lQtCored4
LIBS += -LC:/OSGeo4W/lib/ -lQtGuid4
LIBS += -LC:/OSGeo4W/lib/ -lQtXmld4
}
LIBS += -LC:/OSGeo4W/lib -lgdal_i -lgeos_c
LIBS += -LC:/OSGeo4W/apps/qgis-dev/lib -lqgis_core -lqgis_gui
DEFINES += CORE_EXPORT=__declspec(dllexport)
DEFINES += GUI_EXPORT=__declspec(dllexport)
Это файл .pro для SensorNetworkUI:
CONFIG += console
TARGET = SensorNetwork
TEMPLATE = app
greaterThan(QT_MAJOR_VERSION, 4):
QT += widgets
QT += core gui
QT += opengl
QT += sql
QT += xml
QT += multimedia
INCLUDEPATH += ../
INCLUDEPATH += "C:/OSGeo4W/apps/qgis/include/"
INCLUDEPATH += "C:/OSGeo4W/include/"
win32:CONFIG(Release, Debug|Release) {
LIBS += -LC:/OSGeo4W/lib/ -lQtCore4
LIBS += -LC:/OSGeo4W/lib/ -lQtGui4
LIBS += -LC:/OSGeo4W/lib/ -lQtXml4
}
else:win32:CONFIG(Debug, Debug|Release) {
PRE_TARGETDEPS += C:/OSGeo4W/lib/QtCored4.lib
PRE_TARGETDEPS += C:/OSGeo4W/lib/QtGuid4.lib
PRE_TARGETDEPS += C:/OSGeo4W/lib/QtXmld4.lib
LIBS += -LC:/OSGeo4W/lib/ -lQtCored4
LIBS += -LC:/OSGeo4W/lib/ -lQtGuid4
LIBS += -LC:/OSGeo4W/lib/ -lQtXmld4
}
DEFINES += CORE_EXPORT=__declspec(dllexport)
DEFINES += GUI_EXPORT=__declspec(dllexport)
LIBS += -LC:/OSGeo4W/lib -lgdal_i -lgeos_c
LIBS += -LC:/OSGeo4W/apps/qgis-dev/lib -lqgis_core -lqgis_gui
LIBS += -L../ -ldbmanager -lsnobjects -lpositioning -lsnutils -lmaps
Тем не менее, я получаю такие ошибки:
maps.lib(moc_ClickTool.obj) : error LNK2001: unresolved external symbol "public: virtual class QVariant __thiscall QgsExpression::Function::func(class QList<class QVariant> const &,class QgsFeature const *,class QgsExpression *)" ([email protected]@[email protected]@[email protected]@[email protected]@@@@[email protected]@[email protected]@Z)
MainWindow.obj : error LNK2001: unresolved external symbol "public: virtual class QVariant __thiscall QgsExpression::Function::func(class QList<class QVariant> const &,class QgsFeature const *,class QgsExpression *)" ([email protected]@[email protected]@[email protected]@[email protected]@@@@[email protected]@[email protected]@Z)
Я также заметил, что в предложениях с полным набором предложений, предоставляемых Qt Creator, не включены файлы заголовков QGIS. Означает ли это, что Qt Creator не может их найти? Это не вызывает ошибок после того, как все имя было напечатано. Я даже могу открыть указанные файлы заголовков в Qt Creator.
Может кто-нибудь, пожалуйста, скажите мне, где я иду не так?
EDIT: Это где начинается ошибка:
Creating library ..\SensorNetwork.lib and object ..\SensorNetwork.exp
maps.lib(moc_ClickTool.obj) : error LNK2001: unresolved external symbol "public: virtual class QVariant __thiscall QgsExpression::Function::func(class QList<class QVariant> const &,class QgsFeature const *,class QgsExpression *)" ([email protected]@[email protected]@[email protected]@[email protected]@@@@[email protected]@[email protected]@Z)
MainWindow.obj : error LNK2001: unresolved external symbol "public: virtual class QVariant __thiscall QgsExpression::Function::func(class QList<class QVariant> const &,class QgsFeature const *,class QgsExpression *)" ([email protected]@[email protected]@[email protected]@ABV[email protected]@@@@[email protected]@[email protected]@Z)
maps.lib(MapCanvas.obj) : error LNK2001: unresolved external symbol "public: virtual class QVariant __thiscall QgsExpression::Function::func(class QList<class QVariant> const &,class QgsFeature const *,class QgsExpression *)" ([email protected]@[email protected]@[email protected]@[email protected]@@@@[email protected]@[email protected]@Z)
maps.lib(ClickTool.obj) : error LNK2001: unresolved external symbol "public: virtual class QVariant __thiscall QgsExpression::Function::func(class QList<class QVariant> const &,class QgsFeature const *,class QgsExpression *)" ([email protected]@[email protected]@[email protected]@[email protected]@@@@[email protected]@[email protected]@Z)
maps.lib(moc_MapCanvas.obj) : error LNK2001: unresolved external symbol "public: virtual class QVariant __thiscall QgsExpression::Function::func(class QList<class QVariant> const &,class QgsFeature const *,class QgsExpression *)" ([email protected]@[email protected]@[email protected]@[email protected]@@@@[email protected]@[email protected]@Z)
maps.lib(moc_ClickTool.obj) : error LNK2001: unresolved external symbol "public: virtual class QVariant __thiscall QgsExpression::Function::func(class QList<class QVariant> const &,class QgsExpressionContext const *,class QgsExpression *)" ([email protected]@[email protected]@[email protected]@[email protected]@@@@[email protected]@[email protected]@Z)
MainWindow.obj : error LNK2001: unresolved external symbol "public: virtual class QVariant __thiscall QgsExpression::Function::func(class QList<class QVariant> const &,class QgsExpressionContext const *,class QgsExpression *)" ([email protected]@[email protected]@[email protected]@[email protected]@@@@[email protected]@[email protected]@Z)
maps.lib(MapCanvas.obj) : error LNK2001: unresolved external symbol "public: virtual class QVariant __thiscall QgsExpression::Function::func(class QList<class QVariant> const &,class QgsExpressionContext const *,class QgsExpression *)" ([email protected]@[email protected]@[email protected]@[email protected]@@@@[email protected]@[email protected]@Z)
...
...
maps.lib(MapCanvas.obj) : error LNK2001: unresolved external symbol "public: static struct QMetaObject const QgsRasterDataProvider::staticMetaObject" ([email protected]@@[email protected]@B)
maps.lib(MapCanvas.obj) : error LNK2001: unresolved external symbol "public: static struct QMetaObject const QgsRasterLayer::staticMetaObject" ([email protected]@@[email protected]@B)
maps.lib(ClickTool.obj) : error LNK2001: unresolved external symbol "public: virtual void __thiscall QgsMapTool::renderComplete(void)" ([email protected]@@UAEXXZ)
maps.lib(ClickTool.obj) : error LNK2001: unresolved external symbol "public: virtual bool __thiscall QgsMapTool::isTransient(void)const " ([email protected]@@UBE_NXZ)
maps.lib(ClickTool.obj) : error LNK2001: unresolved external symbol "public: virtual bool __thiscall QgsMapTool::isEditTool(void)const " ([email protected]@@UBE_NXZ)
..\SensorNetwork.exe : fatal error LNK1120: 93 unresolved externals
jom: D:\Atmika\Sensor_Network\build\win32\Debug\SensorNetworkUI\Makefile.Debug [..\SensorNetwork.exe] Error 1120
jom: D:\Atmika\Sensor_Network\build\win32\Debug\SensorNetworkUI\Makefile [debug] Error 2
14:21:50: The process "D:\Qt\Qt5.7.1\Tools\QtCreator\bin\jom.exe" exited with code 2.
Error while building/deploying project Sensor_Network (kit: Desktop Qt 5.7.1 MSVC2015 32bit)
When executing step "Make"
Спасибо .. но как я могу проверить, указывают ли они на правильную версию? Я использовал OSGeo4W для загрузки библиотек qgis и заголовков. – user2522981
Я загружаю последнюю версию, чтобы проверить, но это маловероятно, если вы все скачали сразу. Версия видна и указана обычно непосредственно в имени lib (или с simlinks на linux). Вы получаете ошибку при компиляции самого проекта «SensorNetworkUI»? Или у вас есть более полный журнал построения, чтобы помочь?Кстати, для вашего INCLUDEPATH вам не нужны кавычки или трейлинг/ –
Да .. Я получаю ошибки только при компиляции проекта SensorNetworkUI. – user2522981