【发布时间】:2020-07-31 11:15:41
【问题描述】:
我想使用 Visual Studio 2019 来构建 GDAL。但是我在尝试构建时不断收到错误。
我使用的电脑是 Acer Aspire f 15 F5573G-72CP, CPU 为 i7 7500U 2.7GHz,RAM 为 16GB,操作系统为 Windows 10 64 位
我采取的步骤是:
-
下载 Visual Studio 社区,包括 .NET 桌面开发、通用 Windows 平台开发、使用 C++ 和 Node.js 开发的桌面开发。
-
使用来自 git for windows 的 GIT BASH 来提取 repo https://github.com/OSGeo/GDAL.git 并将其定位到 c:/gdal
-
在 c:/gdal/GDAL/nmake.opt:
3.a.将第 42 行更改为
Line 42: MSVC_VER=19263.b。我取消了第 260 行的注释:
Line 259: # PROJ stuff (required dependency: PROJ >= 6)Line 260: PROJ_INCLUDE = -Id:\install-proj\local\include3.c。未注释第 213 行:
Line 213: WIN64=YES -
还提取了 repo:https://github.com/OSGeo/PROJ.git 位于 c:/proj/PROJ
-
使用 Windows Powershell,
cd c:/gdal/gdal->generate_vcxproj.bat 16.0 64 gdal_vs2019输出如下:
PS C:\gdal\gdal> .\generate_vcxproj.bat 16.0 64 gdal_vs2019
The system cannot find the path specified.
Generating:
"C:\gdal\gdal\gdal_vs2019.vcxproj"
"C:\gdal\gdal\gdal_vs2019.vcxproj.user"
"C:\gdal\gdal\gdal_vs2019.vcxproj.filters"
"C:\gdal\autotest\cpp\gdal_vs2019_test.vcxproj"
"C:\gdal\autotest\cpp\gdal_vs2019_test.vcxproj.user"
"C:\gdal\autotest\cpp\gdal_vs2019_test.vcxproj.filters"
This might take a little while...
Projects done!
Launch Visual Studio IDE
* Open project "C:\gdal\gdal\gdal_vs2019.vcxproj"
* Add project "C:\gdal\autotest\cpp\gdal_vs2019_test.vcxproj"
* Configure Build Dependencies to build the main project before the test project.
* Save solution in .sln file
Done!
PS C:\gdal\gdal>
- 打开Visual Studio 2019,打开一个项目或解决方案,选择C:\gdal\gdal\gdal_vs2019.vcxproj,确保Solution Platforms下拉菜单设置为x64,Build->Build Solution,返回三个错误:
Severity Code Description Project File Line Suppression State
Error U1077 'call' : return code '0x1' gdal_vs2019 C:\gdal\gdal\NMAKE 1
Severity Code Description Project File Line Suppression State
Error U1077 '"C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.26.28801\bin\HostX86\x64\nmake.EXE"' : return code '0x2' gdal_vs2019 C:\gdal\gdal\NMAKE 1
Severity Code Description Project File Line Suppression State
Error MSB3073 The command "chcp 65001 >NUL && nmake -f makefile.vc MSVC_VER=1926 WIN64=1 DEBUG=1 WITH_PDB=1" exited with code 2. gdal_vs2019 C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Microsoft\VC\v160\Microsoft.MakeFile.Targets 46
输出选项卡显示:
1>------ Build started: Project: gdal_vs2019, Configuration: Debug x64 ------
1>
1>Microsoft (R) Program Maintenance Utility Version 14.26.28806.0
1>Copyright (C) Microsoft Corporation. All rights reserved.
1>
1> cd port
1> nmake /nologo /f makefile.vc
1> call prev_dllbuild.bat
1>The system cannot find the path specified.
1>
1>C:\gdal\gdal\port>IF NOT EXIST dllbuild.prev (ECHO 1 ) 1>dllbuild.prev
1>
1>C:\gdal\gdal\port>SET /P PREV_DLLBUILD= 0<dllbuild.prev
1>
1>C:\gdal\gdal\port>IF NOT "1" == "1" (ECHO 1 ) 1>dllbuild.prev
1>NMAKE : fatal error U1077: 'call' : return code '0x1'
1>Stop.
1>NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.26.28801\bin\HostX86\x64\nmake.EXE"' : return code '0x2'
1>Stop.
1>C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Microsoft\VC\v160\Microsoft.MakeFile.Targets(46,5): error MSB3073: The command "chcp 65001 >NUL && nmake -f makefile.vc MSVC_VER=1926 WIN64=1 DEBUG=1 WITH_PDB=1" exited with code 2.
1>Done building project "gdal_vs2019.vcxproj" -- FAILED.
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
我应该如何解决这些错误以成功构建 GDAL?
【问题讨论】:
-
你有幸构建了那个 gdal 版本吗?我自己做不到...
-
不走运。我最终玩了 Anaconda 并以这种方式开始使用 GDAL。见gis.stackexchange.com/a/381491/66545
标签: c++ build visual-studio-2019 gdal