博客
关于我
图解VC++2012编译安装GDAL1.11.0和入门例子
阅读量:101 次
发布时间:2019-02-26

本文共 1167 字,大约阅读时间需要 3 分钟。

相关下载

http://pan.baidu.com/s/1o7OEMc6

gdal1.rar - 入门例子

GDAL书籍代码及数据.rar
gdal1110.zip - 下载的源码
GDAL.rar - 构建成功后的内容

1 进入如下目录执行vcvars32.bat

2 切换到解压目录执行命令

nmake /f makefile.vc,进行编译;时间比较长;可能10几分钟;

完成编译;

3.设置输出目录

找到下载目录中的nmake.opt文件,例如本文的中的文件路径为:
D:\gdal-1.11.0\nmake.opt
打开修改GDAL_HOME的值为安装目录。本文中使用的目录如下:
GDAL_HOME = "D:\GDAL"
应先手动建立D:\GDAL目录

4 构建

切换到解压目录,先后执行

nmake /f makefile.vc install

nmake /f makefile.vc devinstall

构建成功的内容:

5 入门例子

新建控制台工程;添加包含目录、库目录、附加依赖项;并把gdal111.dll拷贝到工程中;

代码;

#include "stdafx.h"#include 
#include
using namespace std;int _tmain(int argc, _TCHAR* argv[]){ GDALDataset *poDataset; //数据集对象指针 GDALAllRegister(); //注册驱动 poDataset = (GDALDataset *) GDALOpen("mosaic.tif" , GA_ReadOnly ); if( poDataset != NULL ) { cout << "RasterXSize:" << poDataset -> GetRasterXSize() << endl; cout << "RasterYSize:" << poDataset -> GetRasterYSize() << endl; cout << "RasterCount:" << poDataset -> GetRasterCount() << endl; GDALClose((GDALDatasetH)poDataset); } getchar(); return 0;}

运行效果;

用到的tif文件等测试数据可在前面链接中下载。

相关链接:

http://malagis.com/win7-vs2010-gdal.html

http://www.cnblogs.com/zhangjun1130/archive/2009/11/13/1602340.html

你可能感兴趣的文章
NO 157 去掉禅道访问地址中的zentao
查看>>
no available service ‘default‘ found, please make sure registry config corre seata
查看>>
No compiler is provided in this environment. Perhaps you are running on a JRE rather than a JDK?
查看>>
no connection could be made because the target machine actively refused it.问题解决
查看>>
No Datastore Session bound to thread, and configuration does not allow creation of non-transactional
查看>>
No fallbackFactory instance of type class com.ruoyi---SpringCloud Alibaba_若依微服务框架改造---工作笔记005
查看>>
No Feign Client for loadBalancing defined. Did you forget to include spring-cloud-starter-loadbalanc
查看>>
No mapping found for HTTP request with URI [/...] in DispatcherServlet with name ...的解决方法
查看>>
No mapping found for HTTP request with URI [/logout.do] in DispatcherServlet with name 'springmvc'
查看>>
No module named 'crispy_forms'等使用pycharm开发
查看>>
No module named cv2
查看>>
No module named tensorboard.main在安装tensorboardX的时候遇到的问题
查看>>
No module named ‘MySQLdb‘错误解决No module named ‘MySQLdb‘错误解决
查看>>
No new migrations found. Your system is up-to-date.
查看>>
No qualifying bean of type XXX found for dependency XXX.
查看>>
No qualifying bean of type ‘com.netflix.discovery.AbstractDiscoveryClientOptionalArgs<?>‘ available
查看>>
No resource identifier found for attribute 'srcCompat' in package的解决办法
查看>>
no session found for current thread
查看>>
No static resource favicon.ico.
查看>>
no such file or directory AndroidManifest.xml
查看>>