【问题标题】:GDAL compilation to .NET (C#) useGDAL 编译到 .NET (C#) 使用
【发布时间】:2016-05-04 13:21:16
【问题描述】:

我想编译 GDAL 库以在 C# 程序中使用。我使用 Microsoft Visual Studio 2013。之前,我编译了 GDAL C++,结果我有 dll 和库(没问题)。接下来我尝试使用instruction 进行编译,因为我想在 C# 程序中使用 GDAL。但是,我并没有低估在这一步中我应该做什么。

创建 SWIG 界面代码 要创建接口,请执行以下命令。

nmake /f makefile.vc interface

重新生成 *PINVOKE.cs 文件时上一步 make 的错误,所以 跳到下一步,它会工作的

我尝试跳过这一步,但总是有相同的异常(如下所示)。结果我没有 dll 可以在 C# 中使用...

    ogr\OsrPINVOKE.cs(192,10): error CS0111: Type 'OSGeo.OGR.OsrPINVOKE' already
        defines a member called 'OsrPINVOKE' with the same parameter types
ogr\OsrPINVOKE.cs(188,10): (Location of symbol related to previous error)
NMAKE : fatal error U1077: '"C:\Program Files (x86)\MSBuild\12.0\bin\csc.EXE"' :
 return code '0x1'
Stop.

我应该如何将 GDAL 编译为 C#?也许你有什么想法。

【问题讨论】:

    标签: c# c++ .net gis gdal


    【解决方案1】:

    您可以在 http://www.gisinternals.com/ 找到已编译的二进制文件

    只需添加对 \bin\gdal\csharp*_csharp.dll 的引用,将 *_wrap.dll 添加到您的输出位置和其他 gdal dll。

    【讨论】:

      【解决方案2】:

      在GdalPINVOKE.cs、OgrPINVOKE.cs、OsrPINVOKE.cs中重复定义类构造函数。

      只需注释掉重复的行。

      【讨论】:

        【解决方案3】:

        只需使用 nuget 包,如果您将 GDAL Native 安装到您的项目中,您将获得您需要的所有 dll 和一些配置 .cs,这样您就可以调用这些库而无需在您的 .cs 上导入它们

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 2011-05-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          相关资源
          最近更新 更多