找不到 "Leptonica" 提供的包配置文件
Could not find a package configuration file provided by "Leptonica"
我正在尝试从 tesseract 4.1.1 源代码生成一个 visual studio 2019 C++ 项目。最后,我想在使用 OCR 结果的自定义解决方案中包含一个 tesseract C++ 项目。
当我执行以下步骤时:
- 下载并解压 tesseract 代码 https://github.com/tesseract-ocr/tesseract/archive/refs/tags/4.1.1.zip 到“C:\tesseract”目录。
- 在 VS 2019 的开发人员命令提示符中执行以下命令:
C:\Windows\System32>cd "C:\tesseract"
C:\tesseract>mkdir build
C:\tesseract>cd build
C:\tesseract\build>cmake ..
我收到这个错误:
Could NOT find PkgConfig (missing: PKG_CONFIG_EXECUTABLE)
CMake Error at CMakeLists.txt:224 (find_package):
Could not find a package configuration file provided by "Leptonica"
(requested version 1.74) with any of the following names:
LeptonicaConfig.cmake
leptonica-config.cmake
Add the installation prefix of "Leptonica" to CMAKE_PREFIX_PATH or set
"Leptonica_DIR" to a directory containing one of the above files. If
"Leptonica" provides a separate development package or SDK, be sure it has
been installed.
-- Configuring incomplete, errors occurred!
See also "C:/tesseract/build/CMakeFiles/CMakeOutput.log".
这里是 CMakeLists.txt 文件的相关部分:
CMakeLists.txt screenshot
find_package(PkgConfig)
if(PKG_CONFIG_EXECUTABLE AND NOT Leptonica_DIR)
pkg_check_modules(Leptonica REQUIRED lept>=${MINIMUM_LEPTONICA_VERSION})
link_directories(${Leptonica_LIBRARY_DIRS})
else()
find_package(Leptonica ${MINIMUM_LEPTONICA_VERSION} REQUIRED CONFIG)
endif()
if (NOT Leptonica_FOUND)
message(FATAL_ERROR "Cannot find required library Leptonica. Quitting!")
endif(NOT Leptonica_FOUND)
find_package(LibArchive)
if(LibArchive_FOUND)
set(HAVE_LIBARCHIVE ON)
endif()
解决方案:
在学习了user898678提供的教程和实验之后,这就是我所学到的。
教程中列出的命令(以及下面提供的列表中的命令)可以在普通命令提示符下执行。它们不需要在 Visual Studio.
的开发人员命令提示符下执行
教程(通常)使它变得非常混乱,因为它们试图包含所有内容和每个场景的步骤。就我而言,我只是在为 Tesseract 寻找一个有效的 VS 项目。这个由user898678提供的blogpost是最有用的。我提炼出 运行 所需的命令如下:
set INSTALL_DIR="C:\Temp\Tesseract"
set PATH=%PATH%;%INSTALL_DIR%\bin
call "C:\Program Files (x86)\Microsoft Visual Studio19\Professional\VC\Auxiliary\Build\vcvars64.bat" x64
set INCLUDE=%INCLUDE%;%INSTALL_DIR%\include
set LIBPATH=%LIBPATH%;%INSTALL_DIR%\lib
git clone --depth 1 https://github.com/DanBloomberg/leptonica.git
cd leptonica
cmake -Bbuild -DCMAKE_BUILD_TYPE=Release ^
-DCMAKE_INSTALL_PREFIX=%INSTALL_DIR% -DCMAKE_PREFIX_PATH=%INSTALL_DIR% ^
-DBUILD_PROG=OFF -DSW_BUILD=OFF -DBUILD_SHARED_LIBS=ON
cmake --build build --config Release --target install
cd ..
git clone -b 4.1.1 --depth 1 https://github.com/tesseract-ocr/tesseract.git
cd tesseract
cmake -Bbuild -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=%INSTALL_DIR% ^
-DCMAKE_PREFIX_PATH=%INSTALL_DIR% ^
-DLeptonica_DIR=%INSTALL_DIR%\lib\cmake ^
-DBUILD_TRAINING_TOOLS=OFF -DSW_BUILD=OFF ^
-DOPENMP_BUILD=OFF -DBUILD_SHARED_LIBS=ON
cmake --build build --config Release --target install
对我来说,剔除散落在命令语法中的所有讨论和说明后,命令变得更容易理解。
有几个教程如何使用 cmake 和 VS 在 windows 上构建 tesseract,例如https://bucket401.blogspot.com/2021/03/building-tesserocr-on-ms-windows-64bit.html (you can ignore end of tutorial - python module), minimalist tesseract or with clang
我正在尝试从 tesseract 4.1.1 源代码生成一个 visual studio 2019 C++ 项目。最后,我想在使用 OCR 结果的自定义解决方案中包含一个 tesseract C++ 项目。
当我执行以下步骤时:
- 下载并解压 tesseract 代码 https://github.com/tesseract-ocr/tesseract/archive/refs/tags/4.1.1.zip 到“C:\tesseract”目录。
- 在 VS 2019 的开发人员命令提示符中执行以下命令:
C:\Windows\System32>cd "C:\tesseract"
C:\tesseract>mkdir build
C:\tesseract>cd build
C:\tesseract\build>cmake ..
我收到这个错误:
Could NOT find PkgConfig (missing: PKG_CONFIG_EXECUTABLE)
CMake Error at CMakeLists.txt:224 (find_package):
Could not find a package configuration file provided by "Leptonica"
(requested version 1.74) with any of the following names:
LeptonicaConfig.cmake
leptonica-config.cmake
Add the installation prefix of "Leptonica" to CMAKE_PREFIX_PATH or set
"Leptonica_DIR" to a directory containing one of the above files. If
"Leptonica" provides a separate development package or SDK, be sure it has
been installed.
-- Configuring incomplete, errors occurred!
See also "C:/tesseract/build/CMakeFiles/CMakeOutput.log".
这里是 CMakeLists.txt 文件的相关部分:
CMakeLists.txt screenshot
find_package(PkgConfig)
if(PKG_CONFIG_EXECUTABLE AND NOT Leptonica_DIR)
pkg_check_modules(Leptonica REQUIRED lept>=${MINIMUM_LEPTONICA_VERSION})
link_directories(${Leptonica_LIBRARY_DIRS})
else()
find_package(Leptonica ${MINIMUM_LEPTONICA_VERSION} REQUIRED CONFIG)
endif()
if (NOT Leptonica_FOUND)
message(FATAL_ERROR "Cannot find required library Leptonica. Quitting!")
endif(NOT Leptonica_FOUND)
find_package(LibArchive)
if(LibArchive_FOUND)
set(HAVE_LIBARCHIVE ON)
endif()
解决方案:
在学习了user898678提供的教程和实验之后,这就是我所学到的。
教程中列出的命令(以及下面提供的列表中的命令)可以在普通命令提示符下执行。它们不需要在 Visual Studio.
的开发人员命令提示符下执行教程(通常)使它变得非常混乱,因为它们试图包含所有内容和每个场景的步骤。就我而言,我只是在为 Tesseract 寻找一个有效的 VS 项目。这个由user898678提供的blogpost是最有用的。我提炼出 运行 所需的命令如下:
set INSTALL_DIR="C:\Temp\Tesseract"
set PATH=%PATH%;%INSTALL_DIR%\bin
call "C:\Program Files (x86)\Microsoft Visual Studio19\Professional\VC\Auxiliary\Build\vcvars64.bat" x64
set INCLUDE=%INCLUDE%;%INSTALL_DIR%\include
set LIBPATH=%LIBPATH%;%INSTALL_DIR%\lib
git clone --depth 1 https://github.com/DanBloomberg/leptonica.git
cd leptonica
cmake -Bbuild -DCMAKE_BUILD_TYPE=Release ^
-DCMAKE_INSTALL_PREFIX=%INSTALL_DIR% -DCMAKE_PREFIX_PATH=%INSTALL_DIR% ^
-DBUILD_PROG=OFF -DSW_BUILD=OFF -DBUILD_SHARED_LIBS=ON
cmake --build build --config Release --target install
cd ..
git clone -b 4.1.1 --depth 1 https://github.com/tesseract-ocr/tesseract.git
cd tesseract
cmake -Bbuild -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=%INSTALL_DIR% ^
-DCMAKE_PREFIX_PATH=%INSTALL_DIR% ^
-DLeptonica_DIR=%INSTALL_DIR%\lib\cmake ^
-DBUILD_TRAINING_TOOLS=OFF -DSW_BUILD=OFF ^
-DOPENMP_BUILD=OFF -DBUILD_SHARED_LIBS=ON
cmake --build build --config Release --target install
对我来说,剔除散落在命令语法中的所有讨论和说明后,命令变得更容易理解。
有几个教程如何使用 cmake 和 VS 在 windows 上构建 tesseract,例如https://bucket401.blogspot.com/2021/03/building-tesserocr-on-ms-windows-64bit.html (you can ignore end of tutorial - python module), minimalist tesseract or with clang