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.


目录
相关文章
|
2月前
|
人工智能 机器人 测试技术
【CMake报错】Cannot specify compile definitions for target “PRIVATE“ which is not built...
【CMake报错】Cannot specify compile definitions for target “PRIVATE“ which is not built...
|
1月前
|
机器学习/深度学习 并行计算 安全
ImportError: DLL load failed while importing libpaddle: 找不到指定的模块问题
【6月更文挑战第7天】ImportError: DLL load failed while importing libpaddle: 找不到指定的模块问题
39 0
|
2月前
|
机器学习/深度学习 并行计算 安全
ImportError: DLL load failed while importing libpaddle: 找不到指定的模块。问题处理
【5月更文挑战第12天】ImportError: DLL load failed while importing libpaddle: 找不到指定的模块。问题处理
446 0
|
2月前
MTK在编译10A的target时报错:make: *** [mmi_feature_check]
MTK在编译10A的target时报错:make: *** [mmi_feature_check]
15 0
|
2月前
解决运行qmake:Project ERROR: Cannot run compiler ‘cl‘. Output:
解决运行qmake:Project ERROR: Cannot run compiler ‘cl‘. Output:
317 0
|
11月前
ORB_SLAM2_CUDA : Make failed - Compiling examples - Undefined References
ORB_SLAM2_CUDA : Make failed - Compiling examples - Undefined References
79 0
关于 CMake编译出出现错误“Could not find compiler set in environment variable RC:” 的解决方法
关于 CMake编译出出现错误“Could not find compiler set in environment variable RC:” 的解决方法
关于 CMake编译出出现错误“Could not find compiler set in environment variable RC:” 的解决方法
codeblocks中出现#error This file requires compiler and library support for the错误时的解决方案
codeblocks中出现#error This file requires compiler and library support for the错误时的解决方案
534 0
codeblocks中出现#error This file requires compiler and library support for the错误时的解决方案
|
开发工具 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
109 0
编译OpenJDK11:configure: error: Target CPU mismatch. We are building for x86_64 but CL is for “版“; exp
编译OpenJDK11:configure: error: Target CPU mismatch. We are building for x86_64 but CL is for “版“; exp
144 0