gdal库集成MrSID库的做法

时间:2022-01-22 16:00:14

作者:朱金灿

来源:http://blog.csdn.net/clever101

首先从Lizardtech网站:http://www.lizardtech.com/download/developer/下载MrSID的SDK,我下载的版本是:MrSID_DSDK-8.5.0.3422。

然后在gdal-1.9.1文件夹(gdal源码文件夹)下找到nmake.opt并打开,修改一下两个地方:

#MRSID_DIR =D:\MrSID_DSDK-8.5.0.3422\MrSID_DSDK-8.5.0.3422-win32-vc9
#MRSID_JP2 = YES

改为:

MRSID_DIR =D:\MrSID_DSDK-8.5.0.3422\MrSID_DSDK-8.5.0.3422-win32-vc9
MRSID_JP2 = YES

再找到MRSID_LIB_LINK宏添加需要链接的库:

!IF DEFINED(MRSID_DIR) || DEFINED(MRSID_RASTER_DIR) || DEFINED(MRSID_LIDAR_DIR)
!IF "$(MRSID_PLUGIN)" != "YES"
MRSID_LIB_LINK = D:\MrSID_DSDK-8.5.0.3422\MrSID_DSDK-8.5.0.3422-win32-vc9\Raster_DSDK\lib\lti_dsdk.lib D:\MrSID_DSDK-8.5.0.3422\MrSID_DSDK-8.5.0.3422-win32-vc9\Lidar_DSDK\lib\lti_lidar_dsdk.lib
!ELSE
MRSID_LIB_LINK = D:\MrSID_DSDK-8.5.0.3422\MrSID_DSDK-8.5.0.3422-win32-vc9\Raster_DSDK\lib\lti_dsdk.lib D:\\MrSID_DSDK-8.5.0.3422\MrSID_DSDK-8.5.0.3422-win32-vc9\Lidar_DSDK\lib\lti_lidar_dsdk.lib
!ENDIF
!ENDIF

然后编译gdal库。

最后测试一下:

#include <iostream>
using namespace std;
#include "gdal_priv.h" int _tmain(int argc, _TCHAR* argv[])
{
GDALAllRegister(); GDALDataset* poDataset = (GDALDataset *) GDALOpen("F:\\MyRes\\xiangyang\\rs[420600][200305][2004].sid", GA_ReadOnly ); if( poDataset != NULL ) { cout<<"RasterXSize:"<<poDataset->GetRasterXSize()<<endl; cout<<"RasterYSize:"<<poDataset->GetRasterYSize()<<endl; cout<<"RasterCount:"<<poDataset->GetRasterCount()<<endl; }
getchar();
return 0;
}