Download, compile and add GDAL library for Visual C++ project in Visual Studio IDE.
What is a GDAL?
is a translator library for raster and vector geospatial data formats that is released under an X/MIT style Open Source license by the Open Source Geospatial Foundation. As a library, it presents a single raster abstract data model and single vector abstract data model to the calling application for all supported formats. It also comes with a variety of useful command line utilities for data translation and processing. The NEWS page describes the June 2018 GDAL/OGR 2.3.1 release.
Source: http://www.gdal.org
Step 1:
Visit in GDAL website (http://www.gdal.org) and go to section "Developer Oriented Documentation" after that enter "Building GDAL From Source".
Link: http://trac.osgeo.org/gdal/wiki/BuildHints
Step 2:
Download source package (I recomend lastest stable release).
For windows it is gdal
example: gdal321.zip
Step 3:
Unzip it uzing 7ZIP, WinRAR or another tool for unzip file.
Step 4:
Run power shell (or command line [cmd.exe]):
Step 5:
Run generate_vcxproj.bat script in Power Shell with parametrs.
Instruction and description:
https://trac.osgeo.org/gdal/wiki/GeneratingVisualStudioProject
Step 6:
Run gdal_vsXXXX.vcxproj in visual studio
Where XXXX - version of visual studio
example: gdal_vs2015.vcxproj
Step 7:
Build project in visual studio
Use Build -> Build Solutions
or use CTRL + SHIFT + B
Sucessful compilation:
Step 8:
Create new Visual C++ project in Visual studio.
Select finish.
Build project for test.
If use x64 processor set project to x64.
Stel 9:
Add GDAL library and other GDAL files to this project.
Select "properties" from project.
In VC++ Directories edit Include Directores:
Add directories:
C:\Users\zoz\Desktop\gdal-2.3.1
C:\Users\zoz\Desktop\gdal-2.3.1\gcore
C:\Users\zoz\Desktop\gdal-2.3.1\apps
C:\Users\zoz\Desktop\gdal-2.3.1\port
C:\Users\zoz\Desktop\gdal-2.3.1\ogr
"zoz" is username.
Add to Library Directories:
$C:\Users\zoz\Desktop\gdal-2.3.1
$C:\Users\zoz\Desktop\gdal-2.3.1\gcore
$C:\Users\zoz\Desktop\gdal-2.3.1\port
$C:\Users\zoz\Desktop\gdal-2.3.1\apps
$C:\Users\zoz\Desktop\gdal-2.3.1\ogr
Add in Linker -> Input -> Additional Dependencies
"C:\Users\zoz\Desktop\gdal-2.3.1\gdal_i.lib"
Click EDIT in this selection
If add GDAL library is could successful build.
#include
Main site of project:
http://www.gdal.org
GDAL FAQ:
http://trac.osgeo.org/gdal/wiki/FAQ
Used softweare:
Windows 10 64-bit PRO
GDAL version: 2.3.1
Microsoft Visual Studio 2015 version 14.0.25431.01 Update 3
Microsoft .NET Framework 4.7.03056
Video on youtube:
https://youtu.be/Yf8rYOfvZjY
Hai Master,
OdpowiedzUsuńMy compilation is failed when i try to build the solution for the generate_vcxproj 11.0 64 gdal_vs2012. Did you have any idea about it?
Few question:
UsuńOS Version?
Visual Studio Version?
C++ Version (not the same as Visual Studio version)
GDAL Version?
I am unable to sail the way you did in the video. till the part we run generate_vcxproj.bat 10.0 32 gdal_vs2010(Because i am having visual studio 2010 and 32 bit with visual c++ version 10.0(i hope it is true)) it works but now when i go to the gdal_vs2010.vcxproj file and try to build it it shows... Build failed nmake -f makefile.vc MSVC_VER=1600 DEBUG=1 WITH PDB=1 exited with code 2. Please help me! Revert back on mail address: hsuccm@gmail.com Thankyou in advance.
OdpowiedzUsuńI recomend update it to Visual Studio 2015 and if you now have 64-bit operating system it is very big problem
UsuńHello,
OdpowiedzUsuńWhen I built .vcxproj I saw these two errors. What should I do now?
1. U1050 PROJ_INCLUDE should be defined. PROJ >= 6 is a required dependency
2. MSB3073 The command "nmake -f makefile.vc MSVC_VER=1910 WIN64=1 DEBUG=1 WITH_PDB=1" exited with code 2.
Few question:
UsuńOS Version?
Visual Studio Version?
C++ Version (not the same as Visual Studio version)
GDAL Version?
i got the same problem
Usuńi use:
win10
visual studio 2019
how do i know the c++ version? i tried several
GDAL 3.0.4
Different person here, but I'm having the same issue with the same error lines.
OdpowiedzUsuńWindows 10 Home 64bit
Both VS2017 and VS2019
VC 14.21.27702
Built my vcxproj with .\generate_vcxproj.bat 14.0 64 gdal_vs2017