gdal2.3在Windows上的编译(VS2015)

1. 环境

操作系统:win10

开发平台:vs2015

GDAL版本:gdal-release-2.3

2. 编译和安装

1.下载并解压

在d盘中新建gdal文件夹将下载好的gdal-release-2.3.zip解压到gdal目录重命名为gdal-2.3并新建gdal_build和gdal_install两个目录.目录结构如下:

d:
├─gdal
    ├─gdal_build
    └─gdal_install
    └─gdal-2.3
        └─源代码文件

2.在gdal-2.3目录下的gdal目录下新建cooperation_party目录,将前面编译《Proj5.0在Window上的编译(VS2015)》《geos-3.8.0在Windows上的cmake编译(VS2015)》Proj4_install,Geos_install目录文件拷贝到cooperation_party目录中

d:
├─gdal
    ├─gdal_build
    └─gdal_install
    └─gdal-2.3
        └─gdal
           └─cooperation_party                
                └─Proj4_install
                └─Geos_install

3.在gdal-2.3目录下的gdal目录下新建创建build.bat文件

@echo off
cd "%~dp0"
echo %cd%
REM 定义gdal_home
set gdal_home="%cd%\..\..\gdal_install" 
echo %gdal_home%
REM 创建gdal_home目录
mkdir %gdal_home%
REM 定义proj_include
set proj_include="%cd%/cooperation_party/Proj4_install/local/include" 
REM 定义proj_library
set proj_library="%cd%/cooperation_party/Proj4_install/local/lib/proj_5_0.lib"
REM 定义geos_include
set geos_library="%cd%/cooperation_party/Geos_install/lib/geos_c.lib"
REM 定义geos_library
set geos_cflags="%cd%/cooperation_party/Geos_install/include"
echo %geos_cflags%
nmake  -f makefile.vc MSVC_VER=1900 WIN64=1 install   GDAL_HOME=%gdal_home% PROJ_INCLUDE=-I%proj_include%  PROJ_LIBRARY=%proj_library%    GEOS_LIB=%geos_library%  GEOS_CFLAGS=-I%geos_cflags%

最终文件目录如下:

d:
├─gdal
    ├─gdal_build
    └─gdal_install
    └─gdal-2.3
        └─gdal
            └─build.bat
            └─cooperation_party               
                └─Proj4_install
                └─Geos_install

3.编译项目

1)启动VS2015 x64兼容命令提示符
2)拖动D:\gdal\gdal-2.3\gdal\build.bat文件到上面打开命令提示符中执行

4.安装项目

修改build.bat命令行参数
开发用

nmake -f makefile.vc MSVC_VER=1900 WIN64=1 devinstall

或发布用

 nmake -f makefile.vc MSVC_VER=1900 WIN64=1 install

3. nmake命令行参数理解

posted @ 2020-09-13 21:30  焦涛  阅读(488)  评论(0编辑  收藏  举报