编译GDAL2.0的一个注意事项

本文介绍了在编译GDAL-2.1.2过程中遇到的‘mt’命令未被识别的问题及其解决方法。该问题源于makefile文件未能正确找到mt.exe的位置。文章提供了具体的修改步骤。

作者:朱金灿

来源:http://blog.youkuaiyun.com/clever101

 

          同事编译gdal-2.1.2,遇到一个编译错误:’mt’不是内部或外部命令,也不是可运行的程序或批处理文件。NMAKE:fatal errorU1077:“if”:返回代码“0x1”,如下图:


        出现这个错误的原因是gdal的makefile文件调用了windows SDK的mt.exe来将manifest文件集成到gdal库中,但是mt.exe的路径并没有被识别。要识别mt.exe,需要在makefile中加上mt.exe的绝对路径或者把mt.exe的路径放入环境变量中。具体是修改makefile.vc的184行

if exist $(GDAL_DLL).manifest mt -manifest$(GDAL_DLL).manifest -outputresource:$(GDAL_DLL);2 

修改为:
if exist $(GDAL_DLL).manifest “C:\ProgramFiles (x86)\Microsoft SDKs\Windows\v7.1A\Bin\mt.exe” -manifest$(GDAL_DLL).manifest -outputresource:$(GDAL_DLL);2

C:\Users\云实>python D:/Python39/Scripts/gdal2tiles.py -z 1-22 D:/UI/min/wechat/xwechat_files/wxid_fvpylr9huzvf22_313b/msg/file/2025-09/芦苇海/NDVI.tif D:/UI/min/wechat/xwechat_files/wxid_fvpylr9huzvf22_313b/msg/file/2025-09/芦苇海/til --xyz --processes 4 A module that was compiled using NumPy 1.x cannot be run in NumPy 2.0.2 as it may crash. To support both 1.x and 2.x versions of NumPy, modules must be compiled with NumPy 2.0. Some module may need to rebuild instead e.g. with 'pybind11>=2.12'. If you are a user of the module, the easiest solution will be to downgrade to 'numpy<2' or try to upgrade the affected module. We expect that some modules will need time to support NumPy 2. Traceback (most recent call last): File "D:\Python39\Scripts\gdal2tiles.py", line 10, in <module> UseExceptions() File "D:\Python39\lib\site-packages\osgeo\gdal.py", line 246, in UseExceptions from . import gdal_array File "D:\Python39\lib\site-packages\osgeo\gdal_array.py", line 10, in <module> from . import _gdal_array Traceback (most recent call last): File "D:\Python39\lib\site-packages\numpy\core\_multiarray_umath.py", line 44, in __getattr__ raise ImportError(msg) ImportError: A module that was compiled using NumPy 1.x cannot be run in NumPy 2.0.2 as it may crash. To support both 1.x and 2.x versions of NumPy, modules must be compiled with NumPy 2.0. Some module may need to rebuild instead e.g. with 'pybind11>=2.12'. If you are a user of the module, the easiest solution will be to downgrade to 'numpy<2' or try to upgrade the affected module. We expect that some modules will need time to support NumPy 2. A module that was compiled using NumPy 1.x cannot be run in NumPy 2.0.2 as it may crash. To support both 1.x and 2.x versions of NumPy, modules must be compiled with NumPy 2.0. Some module may need to rebuild instead e.g. with 'pybind11>=2.12'. If you are a user of the module, the easiest solution will be to downgrade to 'numpy<2' or try to upgrade the affected module. We expect that some modules will need time to support NumPy 2. Traceback (most recent call last): File "D:\Python39\Scripts\gdal2tiles.py", line 13, in <module> from osgeo_utils.gdal2tiles import * # noqa File "D:\Python39\lib\site-packages\osgeo_utils\gdal2tiles.py", line 66, in <module> import osgeo.gdal_array as gdalarray File "D:\Python39\lib\site-packages\osgeo\gdal_array.py", line 10, in <module> from . import _gdal_array Traceback (most recent call last): File "D:\Python39\lib\site-packages\numpy\core\_multiarray_umath.py", line 44, in __getattr__ raise ImportError(msg) ImportError: A module that was compiled using NumPy 1.x cannot be run in NumPy 2.0.2 as it may crash. To support both 1.x and 2.x versions of NumPy, modules must be compiled with NumPy 2.0. Some module may need to rebuild instead e.g. with 'pybind11>=2.12'. If you are a user of the module, the easiest solution will be to downgrade to 'numpy<2' or try to upgrade the affected module. We expect that some modules will need time to support NumPy 2. Usage: gdal2tiles.py [options] input_file [output] gdal2tiles.py: error: Please convert this file to 8-bit and run gdal2tiles on the result. To scale pixel values you can use: gdal_translate -of VRT -ot Byte -scale D:/UI/min/wechat/xwechat_files/wxid_fvpylr9huzvf22_313b/msg/file/2025-09/芦苇海/NDVI.tif temp.vrt then run: gdal2tiles temp.vrt C:\Users\云实>
最新发布
09-03
评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

clever101

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值