• VS2010配置gdal1.10.0 gdal1.10.1编译


    1.gdal1100编译

    正文:

    重要:gdal编译完是release版本的,工程中加载使用时release模式才能用,debug模式使用报错错误LNK2038:检测到“_ITERATOR_DEBUG_LEVEL”的不匹配:值“0”与main.obj中的值“2”不匹配”,即使nmake时设置了debug=1,后继者注意这个坑。

    工程加载使用时注意添加一个lib:#pragma comment(lib,"ws2_32.lib")

    否则报错:error LNK2001: 无法解析的外部符号 __imp_*****

    编译方式1:

    gdal1.10.1的版本编译有vs工程,可直接vs打开sln编译

    编译方式2:

    编辑nmake.opt文件,MSVC_VER=1600

    打开vs的工具命令,cd到gdal目录,执行以下任意一个nmake命令

    新建 bin  ,lib  include文件夹;

    把dll拷贝到bin, gdal.lib  gdal_i.lib拷贝到lib,把所有.h头文件拷贝到include文件夹。

    2.vs2010配置gdal

    不讲了,太简单了:

    1.添加include

    2.添加lib;

    附加依赖:gdal.lib  gdal_i.lib

    3.dll拷贝过来

    再有问题留言吧

    gdal test代码:

    1. #include "stdafx.h"
    2. #include
    3. using namespace std;
    4. #include "gdal_priv.h"
    5. //#pragma comment(lib,"gdal_i.lib")
    6. #pragma comment(lib,"ws2_32.lib")
    7. #include "ogr_geometry.h"
    8. int _tmain(int argc, _TCHAR* argv[])
    9. {
    10. GDALAllRegister();
    11. CPLSetConfigOption("GDAL_FILENAME_IS_UTF8","NO");
    12. CPLSetConfigOption("USE_RRD","YES");
    13. const char* path = "D:\\H47F021001.tif";
    14. GDALDataset * poDataset = (GDALDataset *) GDALOpen(path, GA_ReadOnly);
    15. if(poDataset == NULL)
    16. {
    17. printf("open file fail.\n");
    18. return false;
    19. }
    20. int nImgWidth = poDataset -> GetRasterXSize();
    21. int nImgHeight = poDataset -> GetRasterYSize();
    22. int nBandnum = poDataset -> GetRasterCount();
    23. double *dGeoTrans = new double [6];
    24. poDataset -> GetGeoTransform(dGeoTrans);
    25. printf("Bandnum: %d \n", nBandnum);
    26. printf("ImgWidth: %d \n", nImgWidth);
    27. printf("ImgHeight: %d \n", nImgHeight);
    28. for (int i = 0; i < 6; ++i)
    29. {
    30. printf("GeoTrans %d : %.2f \n", i + 1, dGeoTrans[i]);
    31. }
    32. GDALClose(poDataset);
    33. delete [] dGeoTrans;
    34. system("pause");
    35. return 0;
    36. }

  • 相关阅读:
    微信小程序设计之主体文件app-json-pages
    20个Python面试题来挑战你的知识
    C#【进阶】委托和事件
    vue将base64编码转为pdf方法
    工程管理系统简介 工程管理系统源码 java工程管理系统 工程管理系统功能设计
    【java8】时间日期的使用与格式化
    Oracle共享内存不释放
    12、用户微服务
    SQL2 查询多列
    OpenCompass 大模型评测实战——作业
  • 原文地址:https://blog.csdn.net/xd19890922/article/details/134293161