Compile GDAL in Visual Studio

GDAL is default compiled with makefile. All the source codes are compiled and the lib file is very big.

GDAL supports many raster and vector formats. Most of the formats are not usually used. In VS, we can just compile the formats we will use. This will make the library file smaller.

Except the format-related source files, all other files should be added to project.

We just need to read asc and tif files, so we just add aaigrid and gtiff in frmts to project. Because img file (hfa) is used to generate overview image, so hfa in frmts is also added to project. We don’t need to read vector files, so we don’t add any vector format under ogr/ogrsf_frmts.


General -> Character Set -> Use Multi-Byte Character Set

C/C++ -> General -> Additional Include Directories

Register drivers for selected rater formats

It’s done in function GDALAllRegister of frmts/gdalallregister.cpp. Macro is used to control which drivers are needed to be registered. We just need two formats, so add FRMT_gtiff and FRMT_aaigrid to C/C++ -> Preprocessor -> Preprocessor Definitions to register drivers for these two formats.

It’s done. If new formats are needed, we just need to copy corresponding source files in to frmts, add preprocessor definition for them and compile the project again.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s