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.


目录
相关文章
|
Ubuntu Unix Linux
成功解决ERROR: Unable to find the development tool `cc` in your path; please make sure that you have the
成功解决ERROR: Unable to find the development tool `cc` in your path; please make sure that you have the
成功解决ERROR: Unable to find the development tool `cc` in your path; please make sure that you have the
|
7月前
target overrides the `ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES` build setting defined in `Pods/Target S
target overrides the `ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES` build setting defined in `Pods/Target S
105 0
|
7月前
MTK在编译10A的target时报错:make: *** [mmi_feature_check]
MTK在编译10A的target时报错:make: *** [mmi_feature_check]
31 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错误时的解决方案
735 0
codeblocks中出现#error This file requires compiler and library support for the错误时的解决方案
编译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
174 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
128 0
|
Perl
ld: symbol(s) not found for architecture x86_64 clang: error: linker command failed with exit code 1
ld: symbol(s) not found for architecture x86_64 clang: error: linker command failed with exit code 1
715 0
|
数据可视化 编译器 Windows
关于 CMake“cmake is not able to compile a simple test program”错误 的解决方法
关于 CMake“cmake is not able to compile a simple test program”错误 的解决方法
关于 CMake“cmake is not able to compile a simple test program”错误 的解决方法
|
数据可视化 编译器 Windows
CMake“cmake is not able to compile a simple test program”错误 的解决方法
CMake“cmake is not able to compile a simple test program”错误 的解决方法
1050 0