Compiling and configuring GDAL 3.1.4 based on Visual Studio 2019 under Windows 10


reference resources:

1. Download and install visual studio community 2019:

2. Download and install cmake 3.19.0 (cmake-3.19.0-rc1-win64-x64. MSI):, install options, check add cmake to the system path for all users, open the command prompt after installation, and enter cmake — version to verify whether the configuration is successful;

3. Download the libraries to their respective directories and unzip them:

GDAL 3.1.4:

PROJ 6.3.2:

SQLite 3.33.0 ( under source code, and under precompiled binaries for Windows):

4. Compile SQLite Library:

Create an empty project in SQLite directory and add SQLite3. H, sqlite3ext. H, SQLite3. C and sqlite3.def;

Right click item – properties, configure, select all configurations, select all platforms, and click configuration properties – General – configuration type – static library (. LIB);

Click C / C + + – preprocessor – preprocessor definition – edit add:


Click linker – input – module definition file – add sqlite3.def, and click Apply – OK;

Modify the module definition file sqlite3.def: add SQLite3 at the end_ unlock_ notify;

Select the configuration release and platform x64, and click generate – generate solution to generate the static library sqlite.lib;

Create include, lib and bin folders under SQLite directory, put sqlite.lib into lib folder, SQLite3. H and sqlite3ext. H into include folder, and sqlite3.exe in sqlite-tools-win32-x86-3330000 folder into bin folder.

5. Compile proj Library:

Create the build folder in the proj directory, open cmake, open the proj-6.3.2 folder in the source location, and open the build folder in the creation location;

Click Configure, select visual studio 16, 2019, x64, and click finish;

Configuration error, find exe_ SQLITE3、SQLITE3_ INCLUDE_ Dir and SQLite3_ The three properties of library are assigned the path of sqlite3.exe, include and sqlite3.lib and cmake respectively_ INSTALL_ The prefix attribute is the file generation directory. Click Configure to complete the prompt configuring done. Click generate to complete the prompt generating done. At this time, proj4.sln exists in the build folder;

Open x64 native tools command prompt for vs 2019:

cd d:/PROJ/build
msbuild ALL_BUILD.vcxproj /p:Configuration=”Release”
msbuild INSTALL.vcxproj /p:Configuration=”Release”

6. Compile GDAL Library:

Open the nmake.opt file using Visual Studio 2019, modify and save:

In line 42, change to MSVC_ Ver = 1920 (vs2019 version should be 1920 or above, depending on your compiler);

On line 66, change to GDAL_ Home = path of generated file;

In line 207, change to win64 = Yes (if the 64 bit version is not generated, comment the line);

In line 234, change dllbuild = 0 for static compilation (1 for dynamic compilation);

On line 254, find proj_ INCLUDE、PROJ_ Library, set it to the include and lib folders of proj respectively (path after proj_include = – I), and modify the name of. Lib;

On line 642, find SQLite_ INC、SQLITE_ Lib, the path setting is the same as above;

Open x64 native tools command prompt for vs 2019:

cd d:/GDAL/gdal-3.1.4

Nmake / F (add debug = 1 in the debug version)

nmake /f devinstall

7. To configure GDAL libraries in a visual studio 2019 project:Create an empty visual studio 2019 project, select all configurations for configuration, select all platforms for platform,Right click item – properties-C / C + + – attach include directory – edit and add the include folder path of GDAL,Click linker – attach Library Directory – edit the Lib folder path to add GDAL, and click linker – input – attach dependencies – edit add GDAL_ i. Lib, click application – OK, select release and platform x64 to run the program.



Recommended Today

IOS development crash defense

1. Crash may occur in IOS Unrecognized selector sent to instance Unrecognized selector sent to class KVO Crash KVC Crash NSNotification Crash NSTimer Crash Container crash (crash caused by collection class operations, such as array out of bounds, inserting nil, etc.) Nsstring crash (crash caused by string operation) Bad access crash (wild pointer) Threading crash […]