Gdal 223 Building


Building Gdal2.2.3

Please download GDAL and GEOS pacakge for OSGeo Trac.

Download Source code.

Download GDAL:

Please download version 2.2.3 package.

Build Gdal

After bulid gdal, please first build proj, geos.

  1. 以管理员模式打开VS2015 x64 Native Tools Command Prompt.

  2. 注册64位环境

    cd C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin

    vcvars64.bat

  3. Download swig 3.0.12

    Swig Home

  4. D:\Umanaged\gdal223\gdal-2.2.3文件下,打开nmake.opt文件

Set output folder:

GDAL_HOME = “D:\Umanaged\gdal223\gdal-2.2.3-release\gdal”

SWIG = D:\Umanaged\gdal223\swigwin-3.0.12\swig.exe


集成geos

#GEOS_DIR=C:/warmerda/geos

#GEOS_CFLAGS=-I(GEOSDIR)/capiI(GEOS_DIR)/capi -I

#GEOS_LIB =$(GEOS_DIR)/source/geos_c_i.lib

GEOS_DIR=D:\Umanaged\gdal223\geos-3.5.1

GEOS_CFLAGS = -I(GEOSDIR)/capiI(GEOS_DIR)/capi -I

GEOS_LIB = $(GEOS_DIR)/src/geos_c_i.lib


集成proj

#PROJ_INCLUDE=-Id:\projects\proj.4\src

#PROJ_LIBRARY=d:\projects\proj.4\src\proj_i.lib

PROJ_INCLUDE = -ID:\Umanaged\gdal223\proj-4.9.1\src

PROJ_LIBRARY = D:\Umanaged\gdal223\proj-4.9.1\src\proj_i.lib

  1. Complite

    cd D:\Umanaged\gdal223\gdal-2.2.3

    nmake /f makefile.vc MSVC_VER=1900 WIN64=yes

    nmake /f makefile.vc install MSVC_VER=1900 WIN64=yes

    nmake /f makefile.vc devinstall MSVC_VER=1900 WIN64=yes

  2. Make source code

    nmake /f makefile.vc interface

  3. Fixed code issue:
    AssemblyInfo.cs 文件 -> 注释 // [assembly: AllowPartiallyTrustedCallers]

打开D:\GDAL\gdal-2.2.3\swig\csharp\gdal\GdalPINVOKE.cs
D:\GDAL\gdal-2.2.3\swig\csharp\ogr\OgrPINVOKE.cs
D:\GDAL\gdal-2.2.3\swig\csharp\osr\OsrPINVOKE.cs
->
//static OsrPINVOKE() {
//}

Band.cs|Dataset.cs|Driver.cs ->
public Band(IntPtr cPtr, bool cMemoryOwn, object parent) : base(GdalPINVOKE.Band_SWIGUpcast(cPtr), cMemoryOwn, parent)

public Dataset(IntPtr cPtr, bool cMemoryOwn, object parent) : base(GdalPINVOKE.Dataset_SWIGUpcast(cPtr), cMemoryOwn, parent)

public Driver(IntPtr cPtr, bool cMemoryOwn, object parent) : base(GdalPINVOKE.Driver_SWIGUpcast(cPtr), cMemoryOwn, parent)

Fixed
error CS0246: The type or namespace name ‘HandleRef’ could not be found
error CS0246: The type or namespace name ‘IntPtr’ could not be found

add using:
using System;
using System.Runtime.InteropServices;

  1. Make C# libary.

    nmake /f makefile.vc

    nmake /f makefile.vc install

转载自:https://blog.csdn.net/weixin_43747680/article/details/84951465

You may also like...