3

I have written a QGIS plugin (RTools) which acts mostly like a independent plugin (minimal interaction with QGIS core functions). On Linux both QGIS and RTools were build using QT 4.8 on Qt creator. Everything worked well.

I wanted to make it available on windows too. When I was reading the 'How to build section' of QGIS, it says now QGIS is built on Visual Studio and Mingw is no more supported. My plugin RTools built well with mingw but not on Visual Studio.

What would be a suitable approach/ work around to get this working?


Some progress !!! I am now able to compile under mingw.

I have built qgis1.7.4 under mingw as qgis1.8 depends on spatialindex lib ( I could not build it under mingw). All plugins and binaries are built. When executing, it is not able to load provider or plugins. It shows a message:

"No QGIS data provider plugins found in:
/plugins
No vector layers can be loaded. Check your QGIS installation  " . 

All are built under debug. This is the path information printed on console when run

Application Settings:
--------------------------

Debug: d:/QGis/qgis-1.7.4/qgis-1.7.4/src/app/qgisapp.cpp: 574: (QgisApp) Application state

Prefix              :

Plugin Path         : /plugins 

Package Data Path   : /.

Active Theme Name   : default

Active Theme Path   : :/images/themes/default/

Default Theme Path  : :/images/themes/default/

SVG Search Paths    : /./svg/

C:/Users/user/.qgis/svg/

User DB Path        : /./resources/qgis.db


Debug: d:/QGis/qgis-1.7.4/qgis-1.7.4/src/app/qgisapp.cpp: 575: (QgisApp)

-------------------------- 

It is clear that the prefix is empty.

How can I set it so as to load the providers and plugins?


Complete trace

user@optima1 /d/QGis/qgis-1.7.4/qgis-1.7.4_Build/src/app
$ qgis
Warning: QCoreApplication::applicationDirPath: Please instantiate the QApplication object first
Warning: QCoreApplication::applicationDirPath: Please instantiate the QApplication object first
Warning: loading of qgis translation failed [/./i18n//qgis_en_US]
Warning: loading of qt translation failed [E:/dependencies/qt-everywhere-opensource-src-4.8.4/qt4.8.4/translations/qt_en_US]
Warning: QCoreApplication::applicationDirPath: Please instantiate the QApplication object first
Debug: d:/QGis/qgis-1.7.4/qgis-1.7.4/src/app/qgisapp.cpp: 6789: (namUpdate) setCacheDirectory: C:/Users/user/.qgis/cache
Debug: d:/QGis/qgis-1.7.4/qgis-1.7.4/src/app/qgisapp.cpp: 6790: (namUpdate) setMaximumCacheSize: 52428800
Debug: d:/QGis/qgis-1.7.4/qgis-1.7.4/src/app/qgisapp.cpp: 6793: (namUpdate) cacheDirectory: C:/Users/user/.qgis/cache/
Debug: d:/QGis/qgis-1.7.4/qgis-1.7.4/src/app/qgisapp.cpp: 6794: (namUpdate) maximumCacheSize: 52428800
Debug: d:/QGis/qgis-1.7.4/qgis-1.7.4/src/core/qgscoordinatereferencesystem.cpp: 220: (loadFromDb) failed : /./resources/srs.db does not exist!
Debug: d:/QGis/qgis-1.7.4/qgis-1.7.4/src/core/qgscoordinatetransform.cpp: 144: (initialise) SourceCRS seemed invalid!
Debug: d:/QGis/qgis-1.7.4/qgis-1.7.4/src/core/qgsdistancearea.cpp: 105: (setEllipsoid) Can't open database: unable to open database file
Debug: d:/QGis/qgis-1.7.4/qgis-1.7.4/src/core/qgsscalecalculator.cpp: 43: (setMapUnits) Map units set to 2
Debug: d:/QGis/qgis-1.7.4/qgis-1.7.4/src/core/qgsscalecalculator.cpp: 138: (calculateGeographicDistance) Distance across map extent (m): 0
Debug: d:/QGis/qgis-1.7.4/qgis-1.7.4/src/core/qgsscalecalculator.cpp: 89: (calculate) Using conversionFactor of 39.3701
Debug: d:/QGis/qgis-1.7.4/qgis-1.7.4/src/core/qgsscalecalculator.cpp: 92: (calculate) Can't calculate scale from the input values
Debug: d:/QGis/qgis-1.7.4/qgis-1.7.4/src/core/qgscoordinatereferencesystem.cpp: 220: (loadFromDb) failed : /./resources/srs.db does not exist!
Debug: d:/QGis/qgis-1.7.4/qgis-1.7.4/src/gui/qgsmapcanvasmap.cpp: 47: (resize) resizing to 1x1
Debug: d:/QGis/qgis-1.7.4/qgis-1.7.4/src/core/qgsmaprenderer.cpp: 194: (adjustExtentToSize) Map units per pixel (x,y) : 0, 0

Debug: d:/QGis/qgis-1.7.4/qgis-1.7.4/src/core/qgscoordinatereferencesystem.cpp: 220: (loadFromDb) failed : /./resources/srs.db does not exist!
Debug: d:/QGis/qgis-1.7.4/qgis-1.7.4/src/core/qgscoordinatetransform.cpp: 144: (initialise) SourceCRS seemed invalid!
Debug: d:/QGis/qgis-1.7.4/qgis-1.7.4/src/core/qgsdistancearea.cpp: 105: (setEllipsoid) Can't open database: unable to open database file
Warning: QMetaObject::connectSlotsByName: No matching signal for on_buttonBox_rejected()
Warning: QMetaObject::connectSlotsByName: No matching signal for on_buttonBox_helpRequested()
Debug: d:/QGis/qgis-1.7.4/qgis-1.7.4/src/app/qgsmeasuredialog.cpp: 266: (convertMeasurement) We're measuring on an ellipsoid or using projections, the system is returning meters
Debug: d:/QGis/qgis-1.7.4/qgis-1.7.4/src/app/qgsmeasuredialog.cpp: 266: (convertMeasurement) We're measuring on an ellipsoid or using projections, the system is returning meters
Debug: d:/QGis/qgis-1.7.4/qgis-1.7.4/src/core/qgscoordinatereferencesystem.cpp: 220: (loadFromDb) failed : /./resources/srs.db does not exist!
Debug: d:/QGis/qgis-1.7.4/qgis-1.7.4/src/core/qgscoordinatetransform.cpp: 144: (initialise) SourceCRS seemed invalid!
Debug: d:/QGis/qgis-1.7.4/qgis-1.7.4/src/core/qgsdistancearea.cpp: 105: (setEllipsoid) Can't open database: unable to open database file
Warning: QObject: Cannot create children for a parent that is in a different thread.
(Parent is QgsMapCanvas(0x4c6fe28), parent's thread is QThread(0x4ab27b0), current thread is QThread(0x4c18438)
Debug: d:/QGis/qgis-1.7.4/qgis-1.7.4/src/core/qgscoordinatereferencesystem.cpp: 220: (loadFromDb) failed : /./resources/srs.db does not exist!
Debug: d:/QGis/qgis-1.7.4/qgis-1.7.4/src/core/qgscoordinatetransform.cpp: 144: (initialise) SourceCRS seemed invalid!
Debug: d:/QGis/qgis-1.7.4/qgis-1.7.4/src/core/qgsdistancearea.cpp: 105: (setEllipsoid) Can't open database: unable to open database file
Warning: QMetaObject::connectSlotsByName: No matching signal for on_buttonBox_rejected()
Warning: QMetaObject::connectSlotsByName: No matching signal for on_buttonBox_helpRequested()
Debug: d:/QGis/qgis-1.7.4/qgis-1.7.4/src/app/qgsmeasuredialog.cpp: 266: (convertMeasurement) We're measuring on an ellipsoid or using projections, the system is returning meters
Debug: d:/QGis/qgis-1.7.4/qgis-1.7.4/src/app/qgsmeasuredialog.cpp: 266: (convertMeasurement) We're measuring on an ellipsoid or using projections, the system is returning meters
Debug: d:/QGis/qgis-1.7.4/qgis-1.7.4/src/core/qgscoordinatereferencesystem.cpp: 220: (loadFromDb) failed : /./resources/srs.db does not exist!
Debug: d:/QGis/qgis-1.7.4/qgis-1.7.4/src/core/qgscoordinatetransform.cpp: 144: (initialise) SourceCRS seemed invalid!
Debug: d:/QGis/qgis-1.7.4/qgis-1.7.4/src/core/qgsdistancearea.cpp: 105: (setEllipsoid) Can't open database: unable to open database file
Warning: QObject: Cannot create children for a parent that is in a different thread.
(Parent is QgsMapCanvas(0x4c6fe28), parent's thread is QThread(0x4ab27b0), current thread is QThread(0x4c18438)
Debug: d:/QGis/qgis-1.7.4/qgis-1.7.4/src/core/qgscoordinatereferencesystem.cpp: 220: (loadFromDb) failed : /./resources/srs.db does not exist!
Debug: d:/QGis/qgis-1.7.4/qgis-1.7.4/src/core/qgscoordinatetransform.cpp: 144: (initialise) SourceCRS seemed invalid!
Debug: d:/QGis/qgis-1.7.4/qgis-1.7.4/src/core/qgsdistancearea.cpp: 105: (setEllipsoid) Can't open database: unable to open database file

(Parent is QgsMapCanvas(0x4c6fe28), parent's thread is QThread(0x4ab27b0), current thread is QThread(0x4c18438)
Debug: d:/QGis/qgis-1.7.4/qgis-1.7.4/src/core/qgscoordinatereferencesystem.cpp: 220: (loadFromDb) failed : /./resources/srs.db does not exist!
Debug: d:/QGis/qgis-1.7.4/qgis-1.7.4/src/core/qgscoordinatetransform.cpp: 144: (initialise) SourceCRS seemed invalid!
Debug: d:/QGis/qgis-1.7.4/qgis-1.7.4/src/core/qgsdistancearea.cpp: 105: (setEllipsoid) Can't open database: unable to open database file
Debug: d:/QGis/qgis-1.7.4/qgis-1.7.4/src/core/qgsscalecalculator.cpp: 43: (setMapUnits) Map units set to 2
Debug: d:/QGis/qgis-1.7.4/qgis-1.7.4/src/core/qgsscalecalculator.cpp: 138: (calculateGeographicDistance) Distance across map extent (m): 0
Debug: d:/QGis/qgis-1.7.4/qgis-1.7.4/src/core/qgsscalecalculator.cpp: 89: (calculate) Using conversionFactor of 39.3701
Debug: d:/QGis/qgis-1.7.4/qgis-1.7.4/src/core/qgsscalecalculator.cpp: 92: (calculate) Can't calculate scale from the input values
Debug: d:/QGis/qgis-1.7.4/qgis-1.7.4/src/core/qgscoordinatereferencesystem.cpp: 220: (loadFromDb) failed : /./resources/srs.db does not exist!
Warning: QObject: Cannot create children for a parent that is in a different thread.
(Parent is QgsMapCanvas(0x4c6fe28), parent's thread is QThread(0x4ab27b0), current thread is QThread(0x4c18438)
Warning: QMetaObject::connectSlotsByName: No matching signal for on_cbxEnableTopologicalEditingCheckBox_stateChanged(int)
Debug: d:/QGis/qgis-1.7.4/qgis-1.7.4/src/core/qgsmaprenderer.cpp: 830: (updateFullExtent) called.
Debug: d:/QGis/qgis-1.7.4/qgis-1.7.4/src/core/qgsmaprenderer.cpp: 887: (updateFullExtent) Full extent: Empty
Debug: d:/QGis/qgis-1.7.4/qgis-1.7.4/src/core/qgsmaprenderer.cpp: 223: (render) ========== Rendering ==========
Debug: d:/QGis/qgis-1.7.4/qgis-1.7.4/src/core/qgsmaprenderer.cpp: 227: (render) empty extent... not rendering
Debug: d:/QGis/qgis-1.7.4/qgis-1.7.4/src/core/qgscoordinatereferencesystem.cpp: 220: (loadFromDb) failed : /./resources/srs.db does not exist!
Debug: d:/QGis/qgis-1.7.4/qgis-1.7.4/src/core/qgsmaprenderer.cpp: 664: (setDestinationCrs) * Setting destCRS : =
Debug: d:/QGis/qgis-1.7.4/qgis-1.7.4/src/core/qgsmaprenderer.cpp: 665: (setDestinationCrs) * DestCRS.srsid() = 7
Debug: d:/QGis/qgis-1.7.4/qgis-1.7.4/src/core/qgsmaprenderer.cpp: 668: (setDestinationCrs) Setting DistArea CRS to 7
Debug: d:/QGis/qgis-1.7.4/qgis-1.7.4/src/core/qgscoordinatereferencesystem.cpp: 220: (loadFromDb) failed : /./resources/srs.db does not exist!
Debug: d:/QGis/qgis-1.7.4/qgis-1.7.4/src/core/qgscoordinatetransform.cpp: 144: (initialise) SourceCRS seemed invalid!
Debug: d:/QGis/qgis-1.7.4/qgis-1.7.4/src/core/qgsmaprenderer.cpp: 830: (updateFullExtent) called.
Debug: d:/QGis/qgis-1.7.4/qgis-1.7.4/src/core/qgsmaprenderer.cpp: 887: (updateFullExtent) Full extent: Empty
Debug: d:/QGis/qgis-1.7.4/qgis-1.7.4/src/core/qgsmaprenderer.cpp: 664: (setDestinationCrs) * Setting destCRS : =
Debug: d:/QGis/qgis-1.7.4/qgis-1.7.4/src/core/qgsmaprenderer.cpp: 665: (setDestinationCrs) * DestCRS.srsid() = 7
Debug: d:/QGis/qgis-1.7.4/qgis-1.7.4/src/core/qgsmaprenderer.cpp: 668: (setDestinationCrs) Setting DistArea CRS to 7
Debug: d:/QGis/qgis-1.7.4/qgis-1.7.4/src/core/qgscoordinatereferencesystem.cpp: 220: (loadFromDb) failed : /./resources/srs.db does not exist!
Debug: d:/QGis/qgis-1.7.4/qgis-1.7.4/src/core/qgscoordinatetransform.cpp: 144: (initialise) SourceCRS seemed invalid!
Debug: d:/QGis/qgis-1.7.4/qgis-1.7.4/src/core/qgsmaprenderer.cpp: 830: (updateFullExtent) called.
Debug: d:/QGis/qgis-1.7.4/qgis-1.7.4/src/core/qgsmaprenderer.cpp: 887: (updateFullExtent) Full extent: Empty
Debug: d:/QGis/qgis-1.7.4/qgis-1.7.4/src/gui/qgsmaptool.cpp: 82: (activate) Cursor has been set
Debug: d:/QGis/qgis-1.7.4/qgis-1.7.4/src/core/qgsproviderregistry.cpp: 83: (QgsProviderRegistry) Checking /plugins for provider plugins
Warning: QMetaObject::connectSlotsByName: No matching signal for on_checkBox_toggled(bool)
Debug: d:/QGis/qgis-1.7.4/qgis-1.7.4/src/app/qgisapp.cpp: 4578: (loadPythonSupport) load library libqgispython (1.7.4)
Debug: d:/QGis/qgis-1.7.4/qgis-1.7.4/src/app/qgisapp.cpp: 4586: (loadPythonSupport) Couldn't load Python support library: Cannot load library libqgispython: The specified module could not be fo
Warning: Couldn't load Python support library: Cannot load library libqgispython: The specified module could not be found.
Debug: d:/QGis/qgis-1.7.4/qgis-1.7.4/src/app/qgspluginregistry.cpp: 431: (restoreSessionPlugins) Plugin loading completed
Debug: d:/QGis/qgis-1.7.4/qgis-1.7.4/src/core/raster/qgsrasterlayer.cpp: 197: (buildSupportedRasterFileFilter) Entered
Debug: d:/QGis/qgis-1.7.4/qgis-1.7.4/src/core/raster/qgsrasterlayer.cpp: 2025: (loadProviderLibrary) theProviderKey = gdal
Debug: d:/QGis/qgis-1.7.4/qgis-1.7.4/src/core/raster/qgsrasterlayer.cpp: 2029: (loadProviderLibrary) myLibPath =
Debug: d:/QGis/qgis-1.7.4/qgis-1.7.4/src/core/raster/qgsrasterlayer.cpp: 2051: (loadProviderLibrary) Library name is
Warning: QgsRasterLayer::loadProviderLibrary: Failed to load
Debug: d:/QGis/qgis-1.7.4/qgis-1.7.4/src/core/raster/qgsrasterlayer.cpp: 201: (buildSupportedRasterFileFilter) Could not load gdal provider library
Warning: QObject::connect: Cannot connect (null)::aboutToQuit() to QgisApp::saveWindowState()

Debug: d:/QGis/qgis-1.7.4/qgis-1.7.4/src/gui/qgsmapcanvasmap.cpp: 47: (resize) resizing to 1334x742
Debug: d:/QGis/qgis-1.7.4/qgis-1.7.4/src/core/qgsmaprenderer.cpp: 194: (adjustExtentToSize) Map units per pixel (x,y) : 0, 0

Debug: d:/QGis/qgis-1.7.4/qgis-1.7.4/src/core/qgsmaprenderer.cpp: 195: (adjustExtentToSize) Pixmap dimensions (x,y) : 1334, 742

Debug: d:/QGis/qgis-1.7.4/qgis-1.7.4/src/core/qgsmaprenderer.cpp: 196: (adjustExtentToSize) Extent dimensions (x,y) : 0, 0

Debug: d:/QGis/qgis-1.7.4/qgis-1.7.4/src/core/qgsmaprenderer.cpp: 197: (adjustExtentToSize) Empty
Debug: d:/QGis/qgis-1.7.4/qgis-1.7.4/src/core/qgsscalecalculator.cpp: 138: (calculateGeographicDistance) Distance across map extent (m): 0
Debug: d:/QGis/qgis-1.7.4/qgis-1.7.4/src/core/qgsscalecalculator.cpp: 89: (calculate) Using conversionFactor of 39.3701
Debug: d:/QGis/qgis-1.7.4/qgis-1.7.4/src/core/qgsmaprenderer.cpp: 208: (adjustExtentToSize) Scale (assuming meters as map units) = 1:0
Debug: d:/QGis/qgis-1.7.4/qgis-1.7.4/src/core/qgsmaprenderer.cpp: 223: (render) ========== Rendering ==========
Debug: d:/QGis/qgis-1.7.4/qgis-1.7.4/src/core/qgsmaprenderer.cpp: 227: (render) empty extent... not rendering
Warning: QMetaObject::connectSlotsByName: No matching signal for on_cbxDisableTips_toggled(bool)
Debug: d:/QGis/qgis-1.7.4/qgis-1.7.4/src/app/qgisapp.cpp: 573: (QgisApp)


Application Settings:
--------------------------

Debug: d:/QGis/qgis-1.7.4/qgis-1.7.4/src/app/qgisapp.cpp: 574: (QgisApp) Application state:
Prefix              :
Plugin Path         : /plugins
Package Data Path   : /.
Active Theme Name   : default
Active Theme Path   : :/images/themes/default/
Default Theme Path  : :/images/themes/default/
SVG Search Paths    : /./svg/
C:/Users/user/.qgis/svg/
User DB Path        : /./resources/qgis.db

Debug: d:/QGis/qgis-1.7.4/qgis-1.7.4/src/app/qgisapp.cpp: 575: (QgisApp)
--------------------------
2
  • Solved. Changed setPrefixPath( applicationDirPath(), true ); to setPrefixPath(".", true) ; in qgsapplication.cpp. Able to launch Qgis now.
    – Srikanth
    Commented Apr 26, 2013 at 12:51
  • I would not recommend patching the upstream source files and instead use the API. Or else you will have to reapply your patchset every time you upgrade the QGIS libary. You can also use the methods outlined in the answer to set the prefix path to you working directory ( the "point" ). Commented Apr 27, 2013 at 8:44

1 Answer 1

2

As the question has evolved, sorry for the answer not really matching the title.

When building a custom application using the QGIS libraries, or running stock QGIS, you have to tell the QGIS core, where it will find these libraries (especially the providers). The PyQGIS cookbook contains information which also applies to C++ applications.

This can either be done by setting an appropriate environment variable in a startup script

set QGIS_PREFIX_PATH=C:\Path\To\QGIS\Installation
qgis.exe

or by calling the method QgsApplication::setPrefixPath() before calling QgsApplication::init()

QgsApplication::setPrefixPath( "C:\Path\ToQGIS\Installation" );
QgsApplication::init();

Not the answer you're looking for? Browse other questions tagged or ask your own question.