Sorry for necromancing hte thread, but I am as well trying to link with gdal and there's no way to do it.
I've downloaded the precompiled version from here:
https://trac.osgeo.org/gdal/wiki/BuildingOnWindows
Both DEV and EXE and placed them on the same directory, having now: bin data include and lib.
I've added lib and bin to the PATH and also to LIBS += -L{paths} -lgdal_i and the INCLUDEDIR.
The headers are seen fine, but it can't find the symbols. Here's the error:
moc_gpspublisher.obj:-1: error: LNK2001: unresolved external symbol "public: virtual __cdecl GDALMajorObject::~GDALMajorObject(void)" (??1GDALMajorObject@@UEAA@XZ)
moc_gpspublisher.obj:-1: error: LNK2001: unresolved external symbol "public: virtual __cdecl GDALMajorObject::~GDALMajorObject(void)" (??1GDALMajorObject@@UEAA@XZ)
To copy to clipboard, switch view to plain text mode
I've tried using mingw, but I get the same unresolved symbol (althought at a different place). I've also done a dumpbin of the symbols of the dll:
[...]
159 9E 00005F4C ??1GDALMajorObject@@UAE@XZ
159 9E 00005F4C ??1GDALMajorObject@@UAE@XZ
To copy to clipboard, switch view to plain text mode
[...]
which demangled is:
public: virtual __thiscall GDALMajorObject::~GDALMajorObject(void)
public: virtual __thiscall GDALMajorObject::~GDALMajorObject(void)
To copy to clipboard, switch view to plain text mode
SO I noticed the difference __thiscall and __cdecl. The rellevant part of the code that defines what goes before each function is:
#ifndef CPL_DLL
#if defined(_MSC_VER) && !defined(CPL_DISABLE_DLL)
# define CPL_DLL __declspec(dllexport)
#else
# define CPL_DLL
#endif
#endif
#ifndef CPL_DLL
#if defined(_MSC_VER) && !defined(CPL_DISABLE_DLL)
# define CPL_DLL __declspec(dllexport)
#else
# define CPL_DLL
#endif
#endif
To copy to clipboard, switch view to plain text mode
It's the first option that gets selected. I've tried selecting the second option and also defining it to __thiscall. When I do the first, I actually get the same two errors as in mingw, obviously since in mingw MSC_VER won't be defined. The errors say that the constructor and destructor of the only GDAL object ( OGRSpatialReference oSRS; ) I am declaring are not defined.
main.obj:-1: error: LNK2019: unresolved external symbol "public: __cdecl OGRSpatialReference::OGRSpatialReference(char const *)" (??0OGRSpatialReference@@QEAA@PEBD@Z) referenced in function "public: static void __cdecl GPSReader::project(void)" (?project@GPSReader@@SAXXZ)
main.obj:-1: error: LNK2019: unresolved external symbol "public: __cdecl OGRSpatialReference::OGRSpatialReference(char const *)" (??0OGRSpatialReference@@QEAA@PEBD@Z) referenced in function "public: static void __cdecl GPSReader::project(void)" (?project@GPSReader@@SAXXZ)
To copy to clipboard, switch view to plain text mode
With the second option (forcing __thiscall) I get many more errors, mainly that the left-side modifier cannot modigy pointers to data.
So at this point I wanted to build GDAL from source, but it isn't straightforward. At least on windows.
Am I missing something? How did you get it to work? Is it possible to find a gdal.lib somewhere??
Cheers!
Bookmarks