Index: include/gisdefs.h
===================================================================
--- include/gisdefs.h	(revision 40721)
+++ include/gisdefs.h	(working copy)
@@ -544,7 +544,9 @@
 void G_fpreclass_perform_id(const struct FPReclass *, const CELL *, DCELL *,
 			    int);
 /* gdal.c */
+void G_init_gdal(void);
 struct GDAL_link *G_get_gdal_link(const char *, const char *);
+struct GDAL_link *G_create_gdal_link(const char *, RASTER_MAP_TYPE);
 void G_close_gdal_link(struct GDAL_link *);
 
 /* geodesic.c */
Index: lib/gis/gdal.c
===================================================================
--- lib/gis/gdal.c	(revision 40755)
+++ lib/gis/gdal.c	(working copy)
@@ -1,6 +1,8 @@
 
 #include <stdlib.h>
 #include <string.h>
+#include <unistd.h>
+
 #include <grass/config.h>
 #include <grass/gis.h>
 #include <grass/glocale.h>
@@ -19,8 +21,6 @@
 # ifdef _WIN32
 #  include <windows.h>
 # endif
-# undef CPL_STDCALL
-# define CPL_STDCALL
 #endif
 
 static void CPL_STDCALL(*pGDALAllRegister) (void);
@@ -35,6 +35,22 @@
 					   int nBXSize, int nBYSize,
 					   GDALDataType eBDataType,
 					   int nPixelSpace, int nLineSpace);
+static GDALDriverH CPL_STDCALL(*pGDALGetDriverByName) (const char *);
+static const char *CPL_STDCALL(*pGDALGetMetadataItem) (GDALMajorObjectH,
+						       const char *,
+						       const char *);
+static GDALDatasetH CPL_STDCALL(*pGDALCreate) (GDALDriverH hDriver,
+					       const char *, int, int, int,
+					       GDALDataType, char **);
+static GDALDatasetH CPL_STDCALL(*pGDALCreateCopy) (GDALDriverH, const char *,
+						   GDALDatasetH, int, char **,
+						   GDALProgressFunc, void *);
+static CPLErr CPL_STDCALL(*pGDALSetRasterNoDataValue) (GDALRasterBandH,
+						       double);
+static CPLErr CPL_STDCALL(*pGDALSetGeoTransform) (GDALDatasetH, double *);
+static CPLErr CPL_STDCALL(*pGDALSetProjection) (GDALDatasetH, const char *);
+static const char *CPL_STDCALL(*pGDALGetDriverShortName) (GDALDriverH);
+static GDALDriverH CPL_STDCALL(*pGDALGetDatasetDriver) (GDALDatasetH);
 
 #if GDAL_DYNAMIC
 # if defined(__unix) && !defined(__unix__)
@@ -43,6 +59,16 @@
 
 static void *library_h;
 
+static int G_is_initialized(int *p)
+{
+   return *p;
+}
+
+static void G_initialize_done(int *p)
+{
+   *p = 1;
+}
+
 static void *get_symbol(const char *name)
 {
     void *sym;
@@ -81,8 +107,6 @@
 	"libgdal.so",
 # endif
 # ifdef _WIN32
-	"gdal16.dll",
-	"gdal15.dll",
 	"gdal11.dll",
 	"gdal.1.0.dll",
 	"gdal.dll",
@@ -104,18 +128,36 @@
 {
     load_library();
 
-#ifdef _WIN32
-    pGDALAllRegister   = get_symbol("_GDALAllRegister@0");
-    pGDALOpen          = get_symbol("_GDALOpen@8");
-    pGDALClose         = get_symbol("_GDALClose@4");
+# ifdef _WIN32
+    pGDALAllRegister = get_symbol("_GDALAllRegister@0");
+    pGDALOpen = get_symbol("_GDALOpen@8");
+    pGDALClose = get_symbol("_GDALClose@4");
     pGDALGetRasterBand = get_symbol("_GDALGetRasterBand@8");
-    pGDALRasterIO      = get_symbol("_GDALRasterIO@48");
+    pGDALRasterIO = get_symbol("_GDALRasterIO@48");
+    pGDALGetDriverByName = get_symbol("_GDALGetDriverByName@4");
+    pGDALGetMetadataItem = get_symbol("_GDALGetMetadataItem@12");
+    pGDALCreate = get_symbol("_GDALCreate@28");
+    pGDALCreateCopy = get_symbol("_GDALCreateCopy@28");
+    pGDALSetRasterNoDataValue = get_symbol("_GDALSetRasterNoDataValue@12");
+    pGDALSetGeoTransform = get_symbol("_GDALSetGeoTransform@8");
+    pGDALSetProjection = get_symbol("_GDALSetProjection@8");
+    pGDALGetDriverShortName = get_symbol("_GDALGetDriverShortName@4");
+    pGDALGetDatasetDriver = get_symbol("_GDALGetDatasetDriver@4");
 #else
     pGDALAllRegister = get_symbol("GDALAllRegister");
     pGDALOpen = get_symbol("GDALOpen");
     pGDALClose = get_symbol("GDALClose");
     pGDALGetRasterBand = get_symbol("GDALGetRasterBand");
     pGDALRasterIO = get_symbol("GDALRasterIO");
+    pGDALGetDriverByName = get_symbol("GDALGetDriverByName");
+    pGDALGetMetadataItem = get_symbol("GDALGetMetadataItem");
+    pGDALCreate = get_symbol("GDALCreate");
+    pGDALCreateCopy = get_symbol("GDALCreateCopy");
+    pGDALSetRasterNoDataValue = get_symbol("GDALSetRasterNoDataValue");
+    pGDALSetGeoTransform = get_symbol("GDALSetGeoTransform");
+    pGDALSetProjection = get_symbol("GDALSetProjection");
+    pGDALGetDriverShortName = get_symbol("GDALGetDriverShortName");
+    pGDALGetDatasetDriver = get_symbol("GDALGetDatasetDriver");
 #endif
 }
 
@@ -128,16 +170,38 @@
     pGDALClose = &GDALClose;
     pGDALGetRasterBand = &GDALGetRasterBand;
     pGDALRasterIO = &GDALRasterIO;
+    pGDALGetDriverByName = &GDALGetDriverByName;
+    pGDALGetMetadataItem = &GDALGetMetadataItem;
+    pGDALCreate = &GDALCreate;
+    pGDALCreateCopy = &GDALCreateCopy;
+    pGDALSetRasterNoDataValue = &GDALSetRasterNoDataValue;
+    pGDALSetGeoTransform = &GDALSetGeoTransform;
+    pGDALSetProjection = &GDALSetProjection;
+    pGDALGetDriverShortName = &GDALGetDriverShortName;
+    pGDALGetDatasetDriver = &GDALGetDatasetDriver;
 }
 
 #endif /* GDAL_DYNAMIC */
 
 #endif /* GDAL_LINK */
 
+void G_init_gdal(void)
+{
+#ifdef GDAL_LINK
+    static int initialized;
+
+    if (G_is_initialized(&initialized))
+	return;
+
+    init_gdal();
+    (*pGDALAllRegister) ();
+    G_initialize_done(&initialized);
+#endif
+}
+
 struct GDAL_link *G_get_gdal_link(const char *name, const char *mapset)
 {
 #ifdef GDAL_LINK
-    static int initialized;
     GDALDatasetH data;
     GDALRasterBandH band;
     GDALDataType type;
@@ -214,11 +278,7 @@
     if (req_type != map_type)
 	return NULL;
 
-    if (!initialized) {
-	init_gdal();
-	(*pGDALAllRegister) ();
-	initialized = 1;
-    }
+    G_init_gdal();
 
     data = (*pGDALOpen) (filename, GA_ReadOnly);
     if (!data)
@@ -245,6 +305,14 @@
     return gdal;
 }
 
+struct GDAL_Options
+{
+    const char *dir;
+    const char *ext;
+    const char *format;
+    char **options;
+};
+
 void G_close_gdal_link(struct GDAL_link *gdal)
 {
 #ifdef GDAL_LINK
@@ -256,9 +324,10 @@
 
 #ifdef GDAL_LINK
 CPLErr G_gdal_raster_IO(GDALRasterBandH band, GDALRWFlag rw_flag,
-			int x_off, int y_off, int x_size, int y_size,
-			void *buffer, int buf_x_size, int buf_y_size,
-			GDALDataType buf_type, int pixel_size, int line_size)
+			   int x_off, int y_off, int x_size, int y_size,
+			   void *buffer, int buf_x_size, int buf_y_size,
+			   GDALDataType buf_type, int pixel_size,
+			   int line_size)
 {
     return (*pGDALRasterIO) (band, rw_flag, x_off, y_off, x_size, y_size,
 			     buffer, buf_x_size, buf_y_size, buf_type,

