GDAL编译,源码编译,Visual C++ Build Tools命令提示符安装使用,生成VS工程,编译Java版GDAL

 

1、GDAL 源码下载

http://trac.osgeo.org/gdal/wiki/DownloadSource

下载GDAL相应版本的 cource as a zip:

 

2、编译(nmake)

编译需用VS命令提示符,机器上之前安装的vs2017,nmake,发现是没有的,需要安装 Visual C++ Build Tools.

安装:Visual C++ Build Tools. 

下载地址:http://go.microsoft.com/fwlink/?LinkId=691126

下载后安装即可:

使用的VS2015 x86 x64 Cross Tools Command Prompt,这里要选择一下或试一下,搜过这块的使用,是有区别的:

 

编译主要有三个命令:

nmake -f makefile.vc

nmake -f makefile.vc install

nmake –f makefile.vc devinstall

 

执行第一个命令:

nmake -f makefile.vc

 

如果出现如下报错:

Microsoft (R) Library Manager Version 14.00.24210.0

Copyright (C) Microsoft Corporation.  All rights reserved.

cpl_recode_iconv.obj : warning LNK4221: This object file does not define any previously undefined public symbols, so it will not be used by any link operation that consumes this library

cpl_google_cloud.obj : warning LNK4221: This object file does not define any previously undefined public symbols, so it will not be used by any link operation that consumes this library

        cd ..

        cd gcore

        nmake /nologo /f makefile.vc

        rc -fo Version.res -r -I..\port -I..\ogr Version.rc

'rc' 不是内部或外部命令,也不是可运行的程序

或批处理文件。

NMAKE : fatal error U1077: 'rc' : return code '0x1'

Stop.

NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\BIN\nmake.EXE"' : return code '0x2'

Stop.

出现以上报错,可搜索 rc.exe,将其加入环境变量:

 

 

再执行

如果出现如下报错:

Creating library gdal_i.lib and object gdal_i.exp

LINK : error LNK2001: unresolved external symbol _OSRValidate

LINK : error LNK2001: unresolved external symbol _OPTGetProjectionMethods

LINK : error LNK2001: unresolved external symbol _OGR_G_GetPointCount

LINK : error LNK2001: unresolved external symbol _OGRRegisterAll

LINK : error LNK2001: unresolved external symbol _GDALSimpleImageWarp@36

LINK : error LNK2001: unresolved external symbol _GDALReprojectImage@48

LINK : error LNK2001: unresolved external symbol _GDALComputeMedianCutPCT@32

LINK : error LNK2001: unresolved external symbol _GDALDitherRGB2PCT@28

LINK : error LNK2001: unresolved external symbol _OCTNewCoordinateTransformation@8

odbccp32.lib(dllload.obj) : error LNK2019: unresolved external symbol _vsnwprintf_s referenced in function StringCchPrintfW

gdal202.dll : fatal error LNK1120: 10 unresolved externals

NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\BIN\amd64\link.EXE"' : return code '0x460'

Stop.

在源码中打开namke.opt文件,搜索WIN64,找到下面部分,去掉前面#号:

再次执行:

成功。

 

第二个命令:

nmake -f makefile.vc install

 

 

第三个命令:

nmake -f makefile.vc devinstall

 

执行成功后,在 C盘下会生成warmerda文件夹,bin下有相应生成的.exe 文件:

 

3、生成VS工程

cmd进入gdal目录,执行:generate_vcxproj.bat 14.0 64 gdal-2.3.1

取可生成成功:

 

4、编译Java版GDAL

4.1 下载配置swig:

下载地址:http://www.swig.org/download.html

 

配置环境变量:

 

 

测试安装成功:

出现 Must specify an input file. Use -help for available options. 即表示安装成功了。

 

4.2 下载配置 ant:

ant下载地址:http://ant.apache.org

也可直接访问:https://ant.apache.org/bindownload.cgi

下载解压即可,如下图:

 

配置 E:\test\gdal-2.3.1\nmake.opt ,修改如下两处为相应路径:

Jdk本机已配置好环境变量,可不配置。

 

执行: nmake -f makefile.vc java 取可编译成功。

 

如需支持Postgis,修改配置如下配置文件:

将 PG_INC_DIR 和 PG_LIB 修改为PG安装相应目录

 

修改完成nmake.opt文件之后,重新进行编译即可

 

 

 

如果嫌以上太麻烦,又是使用GDAL的基本功能,可直接下载别人编译好的:

地址:http://www.gisinternals.com/release.php

具体方法见:https://blog.csdn.net/antma/article/details/89264910

 

 

 

 

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

程序员老油条

您的鼓励将是我创作的大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值