title: Build tesseract as DLL Dynamic link library
body: <p>I'm using this .NET wrapper <a href="https://github.com/charlesw/tesseract" rel="nofollow noreferrer">https://github.com/charlesw/tesseract</a> and I wanted to update the included tesseract and leptonica DLLs but after a long google search I was not able to generate them from the original tesseract and leptonica github repositories.</p>
  <p>I already ask on the charlesw repository but did not get any reply (<a href="https://github.com/charlesw/tesseract/issues/486" rel="nofollow noreferrer">https://github.com/charlesw/tesseract/issues/486</a>).</p>
  <p>Any help on how to build the DLLs is much appreciated.</p>
  <p>Thanks!</p>
  <p><a href="https://github.com/tesseract-ocr/tesseract" rel="nofollow noreferrer">https://github.com/tesseract-ocr/tesseract</a>
  <a href="https://github.com/danbloomberg/leptonica" rel="nofollow noreferrer">https://github.com/danbloomberg/leptonica</a></p>
  <p><strong>Answer :</strong> (thank you user898678 for the link)
  Using bucket401 blog post tutorial I extracted the required part to generate:</p>
  <ul>
  <li>leptonica-X.XX.X.dll</li>
  <li>tesseract.exe</li>
  <li>tesseractXX.dll</li>
  </ul>
  <p>and created this buildTesseractLeptonica.bat :</p>
  <pre><code>mkdir buildTesseractLeptonica
  cd buildTesseractLeptonica
  mkdir bin
  
  set INSTALL_DIR=%cd%
  set PATH=%PATH%;%INSTALL_DIR%\bin
  
  call &quot;c:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Auxiliary\Build\vcvars64.bat&quot; x64
  set INCLUDE=%INCLUDE%;%INSTALL_DIR%\include
  set LIBPATH=%LIBPATH%;%INSTALL_DIR%\lib
  set TESSDATA_PREFIX=%INSTALL_DIR%\share\tesseract\tessdata
  
  
  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 --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
  cd ..
  </code></pre>
  <p>bucket401 blog post link: <a href="https://bucket401.blogspot.com/2021/03/building-tesserocr-on-ms-windows-64bit.html" rel="nofollow noreferrer">https://bucket401.blogspot.com/2021/03/building-tesserocr-on-ms-windows-64bit.html</a></p>