`GDALAllRegister@0' when linking GDAL to Qt
-
hello,
I’ve been trying desperately to link GDAL library to Qt (5.0.1) ., but didn’t succeed. I keep getting error messages every times I use a gal function.
@
#include "mainwindow.h"
#include <QApplication>
#include <gdal_priv.h>
#include <cpl_conv.h>
#include <cpl_string.h>int main(int argc, char *argv[])
{
QApplication a(argc, argv);
MainWindow w;
GDALAllRegister();w.show(); return a.exec();
}
@
and my pro file is
@
#-------------------------------------------------Project created by QtCreator 2013-04-07T21:45:42
#-------------------------------------------------
QT += core gui
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
TARGET = sans_titre1
TEMPLATE = appSOURCES += main.cpp
mainwindow.cppHEADERS += mainwindow.h
FORMS += mainwindow.ui
INCLUDEPATH += "D:/gdal-1.9.2/include"
LIBPATH += -L"D:/gdal-1.9.2/lib/"
LIBS += -lgdal_i
@then :
undefined reference to `GDALAllRegister@0'
Please help !
-
Hi ssliz!
I have been successully using GDAL since 1.8.x with both VS and MinGW. From the looks of your PRO file you are using VS. Did you make sure the proper __declspec was set when building the library or the GDAL was built by the same VS as your application?
I have seen this error when both those conditions occur. The former is because no actual symbols are exported. The latter because the name mangling scheme changed between the compilers.
Here is an example of my PRO file that uses GDAL for the OGR spatial referencing.
TARGET = Core
TEMPLATE = lib
VERSION = 1.0.0CONFIG += shared c++11
QT += sql widgetsHEADERS +=
GeodeticToOGR.h
GeodeticToRaw.h
GeodeticToUTM.hSOURCES +=
GeodeticToOGR.cpp
GeodeticToRaw.cpp
GeodeticToUTM.cppINCLUDEPATH +=
$$PWD/../include
$$PWD/..
$$PWD/../../repo-3rd/include
D:/MinGW/msys/1.0/includewin32:CONFIG(release, debug|release): LIBS += -L$$PWD/../../repo-3rd/lib -lgeographic
else:win32:CONFIG(debug, debug|release): LIBS += -L$$PWD/../../repo-3rd/lib -lgeographic
else:unix: LIBS += -L$$PWD/../../repo-3rd/lib -lgeographicwin32:CONFIG(release, debug|release): LIBS += -L$$PWD/../../repo-3rd/lib -lgdal
else:win32:CONFIG(debug, debug|release): LIBS += -L$$PWD/../../repo-3rd/lib -lgdal
else:unix: LIBS += -L$$PWD/../../repo-3rd/lib -lgdal