QGiS Qmake Compile Error (error: undefined reference to `__imp__ZN18QgsUserInputWidgetC1EP7QWidget')
-
@Christian-Ehrlicher Ok Thank you
Can you please share any example of writing a simple QGiS project in Qt C++ or the link to something that can help me learn using QGiS
Everything available online is for PyQGiS only. -
Since I don't use neither QGis nor qmake - not really.
As you can see you link against a lot of qgis libraries, but not against the gui module - add it. -
@Christian-Ehrlicher If I have understood correctly, you meant that I should link library related gui module of QGiS. Can you please let me know how to do it
Or else I haven't understoor properly what you meant. Can you please elaborate the suggestion or solution you provided@Christian-Ehrlicher said in QGiS Qmake Compile Error (error: undefined reference to `__imp__ZN18QgsUserInputWidgetC1EP7QWidget'):
As you can see you link against a lot of qgis libraries, but not against the gui module - add it.
-
@xanthas said in QGiS Qmake Compile Error (error: undefined reference to `__imp__ZN18QgsUserInputWidgetC1EP7QWidget'):
Can you please let me know how to do it
Come on - you already link many libraries - what is the problem to add one more?
LIBS += C:/OSGeo4W/apps/qgis-qt6-dev/lib/qgis_3d.lib \ C:/OSGeo4W/apps/qgis-qt6-dev/lib/qgis_analysis.lib \ C:/OSGeo4W/apps/qgis-qt6-dev/lib/qgis_app.lib \ C:/OSGeo4W/apps/qgis-qt6-dev/lib/qgis_native.lib \ C:/OSGeo4W/apps/qgis-qt6-dev/lib/qgis_server.lib \ ADD_HERE_THEGUI_ONE
-
@jsulm Sorry to be a little annoying here
For me its a bit difficult to understand programming in qt so that's why I asked.
Thank you for the solution
I will try and update hereBy the way is there any way I can have the drag and drop option in design area for qgis in the creator itself?
-
@xanthas said in QGiS Qmake Compile Error (error: undefined reference to `__imp__ZN18QgsUserInputWidgetC1EP7QWidget'):
There can be issue because of the admin permission?
No
Did you do a complete rebuild after changing pro file?
- Delete build folder
- Run qmake
- Build
-
@jsulm I tried it just before typing this reply. Also, since last night I have been trying to contact a few friends of mine who have been working with Qt for a while. The conclusion I have got to is that, this problem lies in QGiS and not with Qt. Also, I can't find answers as there are no tutorials related to QGiS Qt C++ programming. I have asked the same query in their forum as well.
-
@xanthas
I don't use QGIS or Windows. But a little searching and reading implies to me:-
In your stackexchange post I think you do, or might, need to add the
qgis_core
andqgis_gui
libraries. Unless the other libraries use an MSVC feature which auto-adds them. -
Make sure that both QGIS and your code are built using the same compiler. I don't know whether you are compiling QGIS yourself or which compiler you are using. It is clearly intended for MSVC, so make sure you are not using MinGW. Make sure you use the same version of MSVC for both.
-
I have a feeling/hope that you may need to add a couple of DEFINES which you are not doing. In your
.pro
I believe you should have one of
DEFINES += CORE_EXPORT= DEFINES += GUI_EXPORT=
or
DEFINES += CORE_EXPORT=__declspec(dllimport) DEFINES += GUI_EXPORT=__declspec(dllimport)
(possibly the latter). This is an MSVC-ism. Try both (rebuild your code from scratch each time), does it work after e.g. the second pair of definitions?
References:
https://gis.stackexchange.com/questions/244373/qt-c-application-using-qgis-api/246218#246218
https://stackoverflow.com/questions/42201632/qgis-with-standalone-c-application-in-qt-creator
https://3nids.wordpress.com/ -
-
-
Hi,
Why not use the standard notation:
LIBS += -LC:/OSGeo4W/apps/qgis-qt6-dev/lib \ -lqgis_gui \ -lqgis_core
?
-
@JonB Hi these I have already included.
Also, I have seen a few examples at Github. I have tried to compile with MSVC as well as MinGW.
These are the errors:moc_india_map_test.obj:-1: error: LNK2001: unresolved external symbol "public: static struct QMetaObject const QgsVectorLayer::staticMetaObject" (?staticMetaObject@QgsVectorLayer@@2UQMetaObject@@B) moc_india_map_test.obj:-1: error: LNK2001: unresolved external symbol "public: static struct QMetaObject const QgsRasterLayer::staticMetaObject" (?staticMetaObject@QgsRasterLayer@@2UQMetaObject@@B)
after I try to run the project.