Skip to content

Latest commit

 

History

History
76 lines (55 loc) · 1.79 KB

windows-vcpkg.md

File metadata and controls

76 lines (55 loc) · 1.79 KB

Windows Setup with vcpkg

vcpkg is a free C/C++ package manager for acquiring and managing libraries. Choose from over 1500 open source libraries to download and build in a single step or add your own private libraries to simplify your build process. Maintained by the Microsoft C++ team and open source contributors.

Setup vcpkg

vcpkg Installation Guide

For simplicity and easier typing, we install vcpkg in C:\vcpkg.

  1. Clone the vcpkg repo

    cd C:\
    git clone https://github.com/Microsoft/vcpkg.git
  2. Run the bootstrap script to build vcpkg.

    .\vcpkg\bootstrap-vcpkg.bat
  3. Using vcpkg with MSBuild / Visual Studio (may require elevation)

    .\vcpkg.exe integrate install
  4. Set enviornment variable VCPKG_ROOT to be C:\vcpkg.

Install tesseract with vcpkg

(This may take some time)

.\vcpkg.exe install tesseract --triplet x64-windows

Use vcpkg installed tesseract in command line

cmake -B build/ -S . -DCMAKE_TOOLCHAIN_FILE=C:\vcpkg\scripts\buildsystems\vcpkg.cmake
cmake --build build

Use vcpkg installed tesseract in Visual Studio

Add cmakeToolchain setting to cmake preset json file.

"cmakeToolchain": "C:\\vcpkg\\scripts\\buildsystems\\vcpkg.cmake"

An example CMakeSettings.json:

{
  "configurations": [
    {
      "name": "x64-Release",
      "generator": "Ninja",
      "configurationType": "RelWithDebInfo",
      "buildRoot": "${projectDir}\\out\\build\\${name}",
      "installRoot": "${projectDir}\\out\\install\\${name}",
      "cmakeToolchain": "C:\\vcpkg\\scripts\\buildsystems\\vcpkg.cmake",
      "ctestCommandArgs": "",
      "inheritEnvironments": [
        "msvc_x64_x64"
      ]
    }
  ]
}