一、环境
- VS 2017
- Window 10
- GDAL 2.3.0
二、下载MrSID DSDK
- 下载MrSID DSDK:MrSID_DSDK-9.5.4.4709-win64-vc15.zip
- 选择所需的MrSID DSDK版本:
图1 选择相应版本的DSDK
二、配置编译选项
- 指定MSVC_VER=1910 (VS2017)
- 以64位编译:WIN64=YES
- MrSID配置项:MRSID_DIR=%mrsid_dir%(实际mrsid路径), MRSID_JP2=YES
- 以plugin方式编译
D:\gdal\gdal-1.11.1\frmts\mrsid>nmake /f makefile.vc plugin
在nmake.opt中增加:
MRSID_PLUGIN = YES
MRSID_LIDAR_PLUGIN = YES
三、问题解决
- fatal error C1189: PLATFORM ERROR
mrsid_dsdk-9.5.4.4709-win64-vc15\raster_dsdk\include\lt_platform.h(102): fatal error C1189: #error: PLATFORM ERROR: unknown compiler (编译源文件 mrsidstream.cpp)
mrsid_dsdk-9.5.4.4709-win64-vc15\raster_dsdk\include\lt_platform.h(102):fatal error C1189: #error: PLATFORMERROR: unknown compiler (编译源文件 mrsiddataset.cpp)
NMAKE : fatal error U1077: “"C:\ProgramFiles (x86)\Microsoft VisualStudio\2017\Enterprise\VC\Tools\MSVC\14.11.25503\bin\HostX64\x64\cl.EXE"”: 返回代码“0x2”
Stop.
NMAKE : fatal error U1077: “for”: 返回代码“0x1”
Stop.
NMAKE : fatal error U1077: “"C:\ProgramFiles (x86)\Microsoft Visual Studio\2017\Enterprise\VC\Tools\MSVC\14.11.25503\bin\HostX64\x64\nmake.EXE"”: 返回代码“0x2”
Stop.
解决: 修改lt_platform.h中 _MSC_VER <=1910,为符合所用VS2017对应的版本号。
延伸:查看版本号 cl -Bv
图2. 查看VS版本
四、结果测试
- gdalinfo --formats
图3. 查看GDAL支持的格式
2. gdalinfo sid
图4. 读取sid文件
参考:
- MrSID Decode SDK (DSDK): https://www.lizardtech.com/developer/portal-sdk
- Building with MrSID SDK: https://trac.osgeo.org/gdal/wiki/MrSID
- Building on Windows: https://trac.osgeo.org/gdal/wiki/BuildingOnWindows
- How to add MrSID support into GDAL: https://trac.osgeo.org/ubuntugis/wiki/TutorialMrSid
- Building with MrSid support enabled: https://github.com/naturalatlas/node-gdal/issues/88