3

I am trying to develop a C++ application using QGIS. I have to load a tif file and show it. First I wrote an app similar to samples on the internet. It works on Linux, but it does not work on Windows. I compiled QGIS libraries myself using VS2008 and also tried binaries downloaded using Osgeo4w installer.

The app loads the plugins and displays the canvas, but cannot paint the raster layer on it. So I just can see a blank white canvas window.

The debug output says "Layer not found in registry", however I do add it to registry as follows:

QgsMapLayerRegistry::instance()->addMapLayer(myRasterLayer, TRUE);

Any ideas?

  • Have you checked if the layer isValid()? – Snorfalorpagus Mar 18 '15 at 9:12
  • yes. the layer is valid. – Alper Colak Mar 18 '15 at 9:42
  • I printed the address of QgsMapLayerRegistry instance at the beginning of my code and also inside QgsMapLayerRegistry constructor. Two addresses are different. How can a singleton object have a duplicate? – Alper Colak Mar 18 '15 at 11:05
2

Found it!

In Linux, CORE_EXPORT and GUI_EXPORT macros should be set empty,

However in Windows you should define them in .pro file as follows:

DEFINES +=  CORE_EXPORT="__declspec(dllimport)"
DEFINES +=  GUI_EXPORT="__declspec(dllimport)"

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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