![](/img/trans.png)
[英]How to configure and build Tesseract OCR C++ using Visual Studio 2015 x64 on Windows 10
[英]Trying to build GDAL from github using Visual Studio 2019 v16.6.5 on Windows 10 x64
我想使用 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++ 和 Z3B2819DD4C24EDA2FAF2052EEF 開發。
Used GIT BASH from git for windows to pull the repo https://github.com/OSGeo/GDAL.git and located it c:/gdal
在 c:/gdal/GDAL/nmake.opt:
3.a. 將第 42 行更改為第 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
還拉了回購: 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>
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
Output 選項卡顯示:
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?
這有點晚了,但是您是否嘗試過以下操作:
您也可以嘗試清潔:
nmake /f makefile.vc clean
nmake /f makefile.vc
最后,您可以嘗試在另一台計算機上構建。
聽着,這就是提問的方式:清晰、准確的步驟、詳細的描述。 非常有幫助!
當我不使用 GIT 存儲庫時,我可以編譯。 相反,我按照他們的 Windows 安裝文檔下載了 PROJ:
在 Windows 上安裝 PROJ 的最簡單方法是使用
OSGeo4W
_ 軟件分發。 OSGeo4W 提供對許多流行的開源地理空間軟件包的輕松訪問。 安裝后,您可以使用 OSGeo4W shell 中的 PROJ。 要安裝 PROJ,請執行以下操作:注意:: 如果你的電腦上已經通過 OSGeo4W 安裝了軟件,或者你的電腦上已經安裝了 QGIS,那么很可能已經安裝了 PROJ。 在開始菜單中輸入“OSGeo4W Shell”並檢查是否匹配。
- 下載
32 bit
或64 bit
安裝程序。- 運行 OSGeo4W 安裝程序。
- Select “高級安裝”,然后按下一步。
- Select “從 Internet 安裝”,然后按下一步。
- Select 一個安裝目錄。 在大多數情況下,默認建議很好。 按下一步。
- Select “本地 package 目錄”。 在大多數情況下,默認建議很好。 按下一步。
- Select“直接連接”並按下一步。
- 選擇 download.osgeo.org 服務器,然后按下一步。
- 在“Commandline_Utilities”下找到“proj”,點擊“New”欄中的package,直到出現你要安裝的版本。
- 按下一步安裝 PROJ。
我從osgeo4W下載了安裝程序。 因為我需要 32 位和 64 位版本,所以我下載了 osgeo4w-setup-x86-v1.exe 和 osgeo4w-setup-x86_64-v1.exe。 從 osgeo 下載大 proj 文件時,下載在 25% 后卡住了,所以我選擇了 oslandia 下載鏈接。 這最初失敗(至少對我來說),但重新啟動后它可以完成。
在下載 package 選擇中單擊“跳過”標志到 select 二進制(“B”)和源(“S”)。 我兩個都選了。 我下載了“proj”、“proj-dev”和“proj-dev-data”,不確定實際需要什么。 當它要求包含依賴項(很多)時,我選擇包含它們。
在 nmake.opt (您的第 3 步)中,我用於 32 位:
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。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.