[gdal-dev] Doubts about including GDAL libraries in C code using MSVC 2017

Xavier Calaf x.calaf at creaf.uab.cat
Mon Jun 12 01:16:22 PDT 2023


Hello,

I'm trying to use the GDAL libraries in C code in a mapping software to be able to read some raster and vector formats that so far, we can't open and I have doubts about how to include these libraries in the project.

Is there a standard way to proceed or a document that explains step by step how to include them?
And is there a way to implement them without depending on where the DLLs are and just rely on libs?
Both 32-bit and 64-bit versions must be included.
At the final installation of our software there are two executables in the same path, one for each type (32, 64) and I can't get it to recognize the dll's depending on which executable I'm using.

I explain how I did it if there is something wrong:

I have downloaded the Development Kits for the MSVC 2017 compiler release-1911-dev (http://download.gisinternals.com/query.html?content=filelist&file=release-1911-dev.zip) for 32bit and release-1911-x64-dev (http://download.gisinternals.com/query.html?content=filelist&file=release-1911-x64-dev.zip) for 64bit.

I have included the include folder as Additional Include Directories and the lib directory in Additional Library Directories. I also added gdal_i.lib to Additional Dependencies.

At the first test I was able to compile successfully but when running it gave me a system error because it couldn't find the file gdal302.dll. This error appears this before the first line of code.

I saw that it's necessary to register several variables (PATH, GDAL_DATA, GDAL_DRIVER_PATH, PYTHONPATH and PROJ_LIB) and for each variable I added the directories listed in the SDKShell.bat file. After registration, I checked that the variables are registered correctly in the Windows Environment Variables window and the directories are where the codes downloaded from the GDAL libraries are. For example, in the case "GDAL_DATA=%SDK_ROOT%bin\gdal-data" for 64bits, if %SDK_ROOT% is D:\progs\x64\gdalLibs, I specified "GDAL_DATA=D:\progs\x64\gdalLibs\bin \gdal-date".

However, I still have some problems, especially for the 64-bit case, where testing in some cases, after the variable register, it is necessary to restart windows for it to work but it does not always happen.

Thank you very much in advance and I look forward to hearing from you.


P.S. I have also tried using the release-1916-dev version but I had problems compiling the project because it does not find the variables VSIIsLocal(), VSISupportsSequentialWrite() and VSISupportsRandomWrite(). As with the release-1911-dev version, I have been able to compile the project, I have continued to use this version.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/gdal-dev/attachments/20230612/5c30ef21/attachment.htm>


More information about the gdal-dev mailing list