Build with libkml
The author of the OGR/LibKML driver suggest to build against the trunk version of LibKML. The source code is maintained by SVN at http://libkml.googlecode.com/svn/trunk, so you should use SVN command line or TortoiseSVN.
The LibKML source code comes with two Visual Studio 2005. Use the one at the "msvc" folder.
That solution does not include all the needed project, so you should add it after loading the solution on VS 2005.
Note that from the SVN checkout there are more than source code but also some pre-build third part libraries. Those libraries are not build by the existing VS projects but they are going to be needed to build the LibKML driver.
.\libkml\third_party\expat.win32\libexpat.lib .\libkml\third_party\googletest-r108.win32\release\gtest.lib .\libkml\third_party\uriparser-0.7.5.win32\release\uriparser.lib .\libkml\third_party\zlib-1.2.3.win32\lib\minizip.lib .\libkml\third_party\zlib-1.2.3.win32\lib\zdll.lib .\libkml\third_party\zlib-1.2.3.win32\lib\zlib.lib
You should make sure that you have build the whole solution, all the projects, in Release mode preferably.
Now, you should update the file "nmake.opt" at GDAL root folder, uncommenting the lines related to libkml and changing LIBKML_DIR to reflect where LibKML is in your system.
# Uncomment out the following lines to enable LibKML support. LIBKML_DIR = C:/Folder Path/libkml LIBKML_INCLUDE = -I$(LIBKML_DIR)/src -I$(LIBKML_DIR)/third_party/boost_1_34_1 LIBKML_LIBRARY = $(LIBKML_DIR)/msvc/Release LIBKML_LIBS = $(LIBKML_LIBRARY)/libkmlbase.lib \ $(LIBKML_LIBRARY)/libkmlconvenience.lib \ $(LIBKML_LIBRARY)/libkmldom.lib \ $(LIBKML_LIBRARY)/libkmlengine.lib \ $(LIBKML_LIBRARY)/libkmlregionator.lib \ $(LIBKML_LIBRARY)/libkmlxsd.lib \ $(LIBKML_LIBRARY)/minizip_static.lib \ $(LIBKML_DIR)/third_party\expat.win32/libexpat.lib \ $(LIBKML_DIR)/third_party\uriparser-0.7.5.win32/release/uriparser.lib \ $(LIBKML_DIR)/third_party\zlib-1.2.3.win32/lib/minizip.lib \ $(LIBKML_DIR)/third_party\zlib-1.2.3.win32/lib/zlib.lib
Now you can either rebuild, clean and build, all the GDAL project.
nmake -f makefile.vc clean nmake -f makefile.vc nmake -f makefile.vc install
Or you can move to the driver folder and build the driver as a OGR plugin and copy the dll to gdalplugins folder.
.\gdal> cd ogr\ogrsf_frtms\libkml .\gdal\ogr\ogrsf_frtms\libkml> nmake -f makefile.vc ogr_LIBKML.dll .\gdal\ogr\ogrsf_frtms\libkml> copy ogr_LIBKML.dll <gdal path>\bin\gdalplugins
Testing the driver
To test if the driver is been loaded:
.\> ogrinfo --formats Supported Formats: -> "ESRI Shapefile" (read/write) -> "MapInfo File" (read/write) -> "UK .NTF" (readonly) -> "SDTS" (readonly) -> "TIGER" (read/write) -> "S57" (read/write) -> "DGN" (read/write) -> "VRT" (readonly) -> "REC" (readonly) -> "Memory" (read/write) -> "BNA" (read/write) -> "CSV" (read/write) -> "GML" (read/write) -> "GPX" (read/write) -> "LIBKML" (read/write)
And if you have a sample file:
.\> ogrinfo sample.kmz INFO: Open of `sample.kmz' using driver `LIBKML' successful. 1: 0