GDAL1.6 C#库编译备忘

1、下载源代码。
         1)  下载GDAL
1.6,解压到C:\gdal-1.6.0。(http://trac.osgeo.org/gdal/wiki/DownloadSource
     2)
下载Geos3.0.0,(http://trac.osgeo.org/geos/)
     3) 下载swigwin-1.3.36,解压到 C:\gdal-1.6.0\swigwin-1.3.36。 (http://sourceforge.net/project/showfiles.php?group_id=1645)
     4) 下载Proj4.6.1 (http://trac.osgeo.org/proj/)

2、编译GEOS。(http://mateusz.loskot.net/2007/11/26/geos-300rc4-and-visual-c/)

     1)下载: geos-3.0.0.rc4-makefile-fix.zip
     2)nmake /f makefile.vc MSVC_VER=1400

3、编译Proj。
     1) C:\Program Files\Microsoft Visual Studio 8\VC>vcvars32.bat 
       2)
nmake /f makefile.vc all

4、修改GDAL的nmake.opt中如下几处:

!IFNDEF MSVC_VER
#assume msvc 7.1
MSVC_VER=1400
!ENDIF
-------------------------------------------
!IFNDEF GDAL_HOME
GDAL_HOME = "C:\gdal-1.6.0"
!ENDIF
-------------------------------------------
# Set the location of your SWIG installation
!IFNDEF SWIG
SWIG = C:\gdal-1.6.0\swigwin-1.3.36\swig.exe
!ENDIF
-------------------------------------------
# Uncomment for GEOS support
GEOS_DIR=C:\gdal-1.6.0\Geos3.0.0
GEOS_CFLAGS = -I$(GEOS_DIR)/capi -I$(GEOS_DIR)/source/headers -DHAVE_GEOS
GEOS_LIB     = $(GEOS_DIR)/source/geos_c_i.lib

-------------------------------------------
另外:有两个源文件,由于中西文编码的问题会导致编译错误(frmts\leveller\levellerdataset.cpp和frmts\rmf\rmfdataset.cpp)。
解决方法:在vs中打开文件,然后再用ie打开文件,将ie的编码改成西欧,将网页中的代码复制到vs中保存,就行了。

5、编译GDAL

      1) C:\Program Files\Microsoft Visual Studio 8\VC>vcvars32.bat 
      2) nmake /f makefile.vc
      3) nmake /f makefile.vc install
      4) namke /f makefile.vc devinstall

6、将根目录中生成的gdal16.dll 拷贝到目录pymod和swip/csharp中。编译swip,生成gdal-wrap

     1) 转到swip\csharp目录 执行: nmake /f makefile.vc interface 
     2). nmake /f makefile.vc

7、C#库包括:
     gdal16.dll、gdal_csharp.dll、ogr_csharp.dll、osr_csharp.dll、gdalconst_csharp.dll、gdal_wrap.dll、ogr_wrap.dll、osr_wrap.dll、gdalconst_wrap.dll
 、proj.dll、geos_c.dll

posted on 2009-03-27 10:04  Dormouse  阅读(1114)  评论(2编辑  收藏  举报

导航