VS2022编译GDAL库报错: fatal error U1050: PROJ_INCLUDE should be defined. PROJ >= 6 is a required depende

简介: VS2022编译GDAL库报错: fatal error U1050: PROJ_INCLUDE should be defined. PROJ >= 6 is a required depende

场景复现

使用VS2022的Native Tools command prompt for 2022工具编译GDAL库时,报“ fatal error U1050: PROJ_INCLUDE should be defined. PROJ >= 6 is a required depende”错误,这个错误其实是因为缺少PROJ库或者你的PROJ库版本低于6.0导致的。

定位问题

我们可以根据这个错误提示信息,找到对应的代码

makefile.vc(6) : fatal error U1050: PROJ_INCLUDE should be defined.

PROJ >= 6 is a required dependency Stop.


在makefile.vc文件中,发现下面这段代码。这里会对是否有proj路径进行判断,没有则直接报错


!INCLUDE nmake.opt


!IF !DEFINED(PROJ_INCLUDE) !ERROR PROJ_INCLUDE should be defined. PROJ


= 6 is a required dependency !ENDIF


然后在当前路径下的nmake.opt文件中,通过搜索PROJ_INCLUDE,我们可以看到


# PROJ stuff (required dependency: PROJ >= 6)

#PROJ_INCLUDE = -Id:\install-proj\local\include

# Note: add shell32.lib is needed starting with PROJ 7.0 in some circumstances

# for static linking. See https://github.com/OSGeo/gdal/issues/2488

# And ole32.lib also since PROJ 7.1 (see https://github.com/OSGeo/gdal/issues/2743)

#PROJ_LIBRARY = d:\install-proj\local\lib\proj_6_0.lib shell32.lib ole32.lib


可以看到关于PROJ库的相关配置被注释掉了。

原来如此啊,成功找到这个问题的根源了。


解决方案

1、你可以通过降低GDAL库的版本,好像低版本的GDAL库不需要依赖PROJ库。

2、你需要编译PROJ库,但是PROJ库又需要SQLite3库,所以比较复杂,你也可以网上搜对应版本的懒人包,或者参考博文:PROJ 9.1.1源码下载编译(Win10+VS2022) 与SQLite3源码下载与编译(开发环境:Win10+VS2022)。

编译完成后,将对应的链接添加到对应的位置,并且把这段代码放开

# PROJ stuff (required dependency: PROJ >= 6)
PROJ_INCLUDE = -I D:\proj\include
# Note: add shell32.lib is needed starting with PROJ 7.0 in some circumstances
# for static linking. See https://github.com/OSGeo/gdal/issues/2488
# And ole32.lib also since PROJ 7.1 (see https://github.com/OSGeo/gdal/issues/2743)
PROJ_LIBRARY = D:\proj\lib\RelWithDebInfo\proj.lib shell32.lib ole32.lib


踩过的坑

需要注意PROJ_INCLUDE后面的-I千万不能删除。否则就会报如下错误。

cl: 命令行 warning D9024 :无法识别的源文件类型“D:\proj\include”,假定为对象文件 cl: 命令行

warning D9024 :无法识别的源文件类型“D:\proj\include”,假定为对象文件 cl: 命令行 warning

D9024 :无法识别的源文件类型“D:\proj\include”,假定为对象文件 cl: 命令行 warning D9024

:无法识别的源文件类型“D:\proj\include”,假定为对象文件 gdal_translate_bin.cpp LINK :

fatal error LNK1181: 无法打开输入文件“D:\proj\include.obj” NMAKE : fatal error

U1077: “cl”: 返回代码“0x2” Stop. NMAKE : fatal error U1077: ““D:\Program

Files\Microsoft Visual

Studio\2022\Community\VC\Tools\MSVC\14.32.31326\bin\HostX64\x64\nmake.EXE””:

返回代码“0x2” Stop.


目录
相关文章
|
3月前
|
计算机视觉 Python
python opencv:ERROR: Could not find a version that satisfies the requirement opencv ERROR:
python opencv:ERROR: Could not find a version that satisfies the requirement opencv ERROR:
65 2
|
安全 Python
python库ffmpeg的错误解决方法:“Couldn‘t find ffmpeg or avconv - defaulting to ffmpeg, but may not work“
简介:python库ffmpeg的错误解决方法:“Couldn‘t find ffmpeg or avconv - defaulting to ffmpeg, but may not work“
python库ffmpeg的错误解决方法:“Couldn‘t find ffmpeg or avconv - defaulting to ffmpeg, but may not work“
|
11月前
|
Python
python离线安装环境 解决 ERROR: Could not find a version that satisfies the requirement xxx 以及winError[10061]
python离线安装环境 解决 ERROR: Could not find a version that satisfies the requirement xxx 以及winError[10061]
496 0
|
缓存 PHP
Composer报错: require(): Failed opening required ‘.../markbaker/matrix/.../functions/adjoint.php‘
Composer报错: require(): Failed opening required ‘.../markbaker/matrix/.../functions/adjoint.php‘
197 0
|
开发工具 git
编译pluma:configure.ac:229: error: required file ‘pluma/mate-submodules/Makefile.in‘ not found
编译pluma:configure.ac:229: error: required file ‘pluma/mate-submodules/Makefile.in‘ not found
98 0
【解决方案】成功解决ERROR: Could not build wheels for opencv-python, which is required to install pyproject.toml-based projects报错信息
成功解决ERROR: Could not build wheels for opencv-python, which is required to install pyproject.toml-based projects报错信息
【解决方案】成功解决ERROR: Could not build wheels for opencv-python, which is required to install pyproject.toml-based projects报错信息
codeblocks中出现#error This file requires compiler and library support for the错误时的解决方案
codeblocks中出现#error This file requires compiler and library support for the错误时的解决方案
466 0
codeblocks中出现#error This file requires compiler and library support for the错误时的解决方案
onnx-tensorrt:builtin_op_importers.cpp:628:5: error: ‘IIdentityLayer’ is not a member of ‘nvinfer1’
onnx-tensorrt:builtin_op_importers.cpp:628:5: error: ‘IIdentityLayer’ is not a member of ‘nvinfer1’
78 0
|
PyTorch 算法框架/工具
THCudaCheck FAIL file=/pytorch/aten/src/THC/THCGeneral.cpp line=405 error=11 : invalid argument
THCudaCheck FAIL file=/pytorch/aten/src/THC/THCGeneral.cpp line=405 error=11 : invalid argument
139 0
THCudaCheck FAIL file=/pytorch/aten/src/THC/THCGeneral.cpp line=405 error=11 : invalid argument
|
并行计算 C++
错误解决:src/cpp/cuda.hpp:  fatal error: cuda.h
错误解决:src/cpp/cuda.hpp:  fatal error: cuda.h
85 0

热门文章

最新文章