gdal3.0在Windows上的编译(VS2015)

1. 环境

操作系统:win10

开发平台:vs2015

GDAL版本:gdal-release-3.0.0

2. 编译和安装

1.下载并解压

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

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

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

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

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

@echo off
cd "%~dp0"
echo %cd%
REM 定义gdal_home
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/include" 

REM 定义proj_library
set proj_library="%cd%/cooperation_party/Proj4_install/lib/proj.lib" 
REM 定义sqlite3_include
set sqlite3_include="%cd%/cooperation_party/sqlite3_install/include"
REM 定义sqlite3_library
set sqlite3_library="%cd%/cooperation_party/sqlite3_install/lib/SQLite3.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  GDAL_HOME=%gdal_home% PROJ_INCLUDE=-I%proj_include%  PROJ_LIBRARY=%proj_library%  SQLITE_INC=-I%sqlite3_include%  SQLITE_LIB=%sqlite3_library%  GEOS_LIB=%geos_library%  GEOS_CFLAGS=-I%geos_cflags%

最终文件目录如下:

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

3.编译项目

1)启动VS2015 x64兼容命令提示符
2)拖动D:\gdal\gdal-3.0\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 20:37  焦涛  阅读(1037)  评论(0编辑  收藏  举报