1

我发现非常需要绑定到名为 GDAL 的库。 https://github.com/craig-dillabaugh/gdal

没有使用示例的问题。在我从未使用过任何绑定之前。

dub.json 包含下一个字符串: "libs" : ["gdal"]

因此,它似乎需要具有此名称的 lib 文件。

在旧的提交中,我发现了没有配音的编译示例:dmd test_gdal_d.d gdal.d -L-ldgal

原始 gdal 发行版不包含具有此类名称的 lib。只有gdal111.dlllib。所以我将它转换implibgdal111.lib. 有命令implib /s gdal111.lib gdal111.dll

从 11MB 的 lib 变成 1MB 的大小。

使用 Dependency Walker,我查看了符号表。它的符号就像GDALGetRasterXSize 我正在尝试使用下一个命令构建所有符号:

dmd D:\code\binding\gdal-master\gdal-master\source\App.d D:\code\binding\gdal-master\gdal-master\source\gdal.d -L -Igdal111.lib

但我收到下一个错误:

D:\code\binding\gdal-master\gdal-master>dmd D:\code\binding\gdal-master\gdal-master\source\App.d D:\code\binding\gdal-master\gdal-master\source\gdal.d -L -Igdal111.lib OPTLINK (R) for Win32 Release 8.00.17 Copyright (C) Digital Mars 1989-2013 All rights reserved. http://www.digitalmars.com/ctg/optlink.html App.obj(App) Error 42: Symbol Undefined _GDALClose App.obj(App) Error 42: Symbol Undefined _GDALGetRasterCount App.obj(App) Error 42: Symbol Undefined _GDALGetRasterXSize App.obj(App) Error 42: Symbol Undefined _GDALGetRasterYSize App.obj(App) Error 42: Symbol Undefined _GDALOpen App.obj(App) Error 42: Symbol Undefined _GDALAllRegister App.obj(App) Error 42: Symbol Undefined _GDALIdentifyDriver App.obj(App) Error 42: Symbol Undefined _GDALCreate --- errorlevel 8

我把所有东西都存档在这里http://dlang.ru/gdal-d-binding.zip

UPD:我运行了 GDAL !!!

我的要点是添加字符串: pragma( lib, "libgdal.lib" );例如,它已经运行了。很快我希望将一些代码推送到 github。

4

1 回答 1

2

writing up the solution we got together from the comments here:

First, you need to make the lib file. implib can be downloaded here ftp.digitalmars.com/bup.zip and you just run it on the dll, implib /s ldgal.lib ldgal.dll to generate the import library.

Once that is made, you need to add it to the build. There's two ways to do that: add ldgal.lib to the end of the command line to dmd (without any other switches, just add the file, dmd will see that it is a .lib and do the right thing) or add pragma(lib, "ldgal"); to your main source file.

于 2015-04-11T12:18:57.387 回答