Geographic Information Systems Asked by skew_t_pie on April 16, 2021
I am working on a project that uses QGIS within another application using QT Creator. When I try loading my raster data (using C++ API), I get a SIGSEGV
error that traces back to my GDAL provider plugin library.
However, when testing the validity of my data just using the QGIS standalone application, it loads just fine.
I am using QGIS 3.8 and Qt 5.11.3 on a Fedora Linux OS (v28) with GDAL 2.4. I noticed several warnings related to my libproj.so
version possibly conflicting with gdal and sqlite when building QGIS from source (Fedora 28 is EOL and I needed newer versions for the application I’m working on; OS choice is out of my hands, unfortunately) so it might be due to that. But here is my main.cpp
:
#include "mainwindow.h"
#include "qgsapplication.h"
#include "qgsproviderregistry.h"
#include <QApplication>
#include <QString>
int main(int argc, char *argv[])
{
qputenv("QT_STYLE_OVERRIDE",0);
QApplication a(argc, argv);
QgsApplication b(argc, argv, true);
QString qgis_pfx = "/home/me/qgis";
QString gdal_path = "/usr/local/lib/gdalplugins";
QgsProviderRegistry::instance(gdal_path);
b.setPrefixPath(qgis_pfx,true);
b.setPluginPath(qgis_pfx+"/lib");
b.initQgis();
MainWindow w;
w.show();
return a.exec();
return b.exec();
b.exitQgis();
}
and the snippet of code that segfaults in mainwindow.cpp between ‘#’:
QString raster_path = "/home/me/data/raster_01.tif";
QString raster_name = "Surface Temperature (C)";
QString raster_provider = "gdal";
#QgsRasterLayer *r_l = new QgsRasterLayer(raster_path,raster_name,raster_provider);#
and the backtrace:
...received signal SIGSEGV, Segmentation fault.
0x00007fffc9bf0ef3 in int QAtomicOps<int>::load<int>(std::atomic<int> const&) ()
from /home/me/qgis/lib/qgis/plugins/libgdalprovider.so
I’ve narrowed it down to either
a) bad/incomplete QGIS install or
b) improper use of the C++ API.
I have the needed libraries set in my LD_LIBRARY_PATH
and in the .pro file along with needed include paths and have set a few other variables such as GDAL_DATA
prior to launching the app. The next debug step is to try an example of this in Python and see if that results in similar problems. Will also show for the record that the raster does indeed load in QGIS GUI, so it’s probably not the data itself:
Get help from others!
Recent Questions
Recent Answers
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP