【问题标题】:Trying to build GDAL from github using Visual Studio 2019 v16.6.5 on Windows 10 x64尝试在 Windows 10 x64 上使用 Visual Studio 2019 v16.6.5 从 github 构建 GDAL
【发布时间】: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 位

我采取的步骤是:

  1. 下载 Visual Studio 社区,包括 .NET 桌面开发、通用 Windows 平台开发、使用 C++ 和 Node.js 开发的桌面开发。

  2. 使用来自 git for windows 的 GIT BASH 来提取 repo https://github.com/OSGeo/GDAL.git 并将其定位到 c:/gdal

  3. 在 c:/gdal/GDAL/nmake.opt:

    3.a.将第 42 行更改为 Line 42: MSVC_VER=1926

    3.b。我取消了第 260 行的注释:

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

    Line 260: PROJ_INCLUDE = -Id:\install-proj\local\include

    3.c。未注释第 213 行:Line 213: WIN64=YES

  4. 还提取了 repo:https://github.com/OSGeo/PROJ.git 位于 c:/proj/PROJ

  5. 使用 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>
  1. 打开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


【解决方案1】:

这有点晚了,但是您是否尝试过以下方法:

您也可以尝试清洁:

nmake /f makefile.vc clean
nmake /f makefile.vc

最后,您可以尝试在另一台计算机上构建。

【讨论】:

    【解决方案2】:

    听着,这就是提问的方式:清晰、准确的步骤、详细的描述。很有帮助!

    我可以在不使用 GIT 存储库时进行编译。相反,我按照他们的 Windows 安装文档下载了 PROJ:

    在 Windows 上安装 PROJ 的最简单方法是使用 OSGeo4W_ 软件分发。 OSGeo4W 可以轻松访问许多流行的 开源地理空间软件包。安装后可以 使用 OSGeo4W shell 中的 PROJ。要安装 PROJ,请执行以下操作:

    注意:: 如果您已经通过 OSGeo4W 在您的计算机上安装了软件,或者如果 您已经在计算机上安装了 QGIS,PROJ 很可能是 已安装。在开始菜单中输入“OSGeo4W Shell”并检查是否 这给出了一个匹配。

    1. 下载32 bit64 bit 安装程序。
    2. 运行 OSGeo4W 安装程序。
    3. 选择“高级安装”并按下一步。
    4. 选择“从 Internet 安装”并按下一步。
    5. 选择安装目录。在大多数情况下,默认建议很好。按下一步。
    6. 选择“本地包目录”。在大多数情况下,默认建议很好。按下一步。
    7. 选择“直接连接”并按下一步。
    8. 选择 download.osgeo.org 服务器并按下一步。
    9. 在“Commandline_Utilities”下找到“proj”,点击“New”栏中的包,直到出现要安装的版本。
    10. 按下一步安装 PROJ。

    我从osgeo4W 下载了安装程序。因为我需要 32 位和 64 位版本,所以我下载了 osgeo4w-setup-x86-v1.exe 和 osgeo4w-setup-x86_64-v1.exe。从 osgeo 下载大项目文件时,下载在 25% 后卡住了,所以我选择了 oslandia 下载链接。这最初会失败(至少对我而言),但重新启动后它可能会完成。

    在下载包选择中点击“Skip”标志选择二进制(“B”)和源(“S”)。我两个都选了。我下载了“proj”、“proj-dev”和“proj-dev-data”,不确定实际需要什么。当它要求包含依赖项(很多)时,我选择包含它们。

    在我用于 32 位的 nmake.opt(您的第 3 步)中:

    PROJ_INCLUDE = -IC:\OSGeo4W\include
    PROJ_LIBRARY = C:\OSGeo4W\lib\proj.lib
    

    对于 64 位:

    PROJ_INCLUDE = -IC:\OSGeo4W64\include
    PROJ_LIBRARY = C:\OSGeo4W64\lib\proj.lib
    

    为了运行 generate_vcxproj.bat,我使用了 Visual Studio 2022 x86 和 x64 本机工具命令提示符。在我更改的 bat 文件中:

    if "%_vcver_%"=="16.0" (
        set _clver_=1926
        set _vstoolset_=v143
    

    在nmake.opt中:

    MSVC_VER=1929
    

    我分别为 64 位和 32 位运行 bat:

    generate_vcxproj.bat 16.0 64 gdal_vs2022
    generate_vcxproj.bat 16.0 32 gdal_vs2022_x86
    

    在这一步之后,我可以在 Visual Studio 中打开 vcxproj 文件并编译库。我在我的项目中使用了生成的 gdal_i.lib 和随附的 gdal303.dll。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-09-21
      • 1970-01-01
      • 2017-01-12
      • 2021-02-18
      • 1970-01-01
      • 2021-08-05
      • 2017-10-16
      • 1970-01-01
      相关资源
      最近更新 更多