Build tesseract as DLL Dynamic link library - c++

I'm using this .NET wrapper https://github.com/charlesw/tesseract 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.
I already ask on the charlesw repository but did not get any reply (https://github.com/charlesw/tesseract/issues/486).
Any help on how to build the DLLs is much appreciated.
Thanks!
https://github.com/tesseract-ocr/tesseract
https://github.com/danbloomberg/leptonica
Answer : (thank you user898678 for the link)
Using bucket401 blog post tutorial I extracted the required part to generate:
leptonica-X.XX.X.dll
tesseract.exe
tesseractXX.dll
and created this buildTesseractLeptonica.bat :
mkdir buildTesseractLeptonica
cd buildTesseractLeptonica
mkdir bin
set INSTALL_DIR=%cd%
set PATH=%PATH%;%INSTALL_DIR%\bin
call "c:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Auxiliary\Build\vcvars64.bat" 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 ..
bucket401 blog post link: https://bucket401.blogspot.com/2021/03/building-tesserocr-on-ms-windows-64bit.html

There are several tutorials you can follow:
https://bucket401.blogspot.com/2021/03/building-tesserocr-on-ms-windows-64bit.html
http://spell.linux.sk/building-minimalistic-tesseract
https://github.com/tesseract-ocr/tessdoc/blob/main/Compiling.md#windows

Related

Updating cmake on gitlab runner for macos

I'm using a shell gitlab runner on my macbook. It's task is currently to run a very simple yaml file to build my project using cmake.
build:
before_script:
- git submodule update --init --recursive
- mkdir cmake-build-debug
- cmake -DCMAKE_BUILD_TYPE=Debug -G "CodeBlocks - Unix Makefiles" .
script:
- cmake --build . --target all -- -j 4
It returns this though: CMake 3.17 or higher is required. You are running version 3.16.3.
When I add - which cmake to my before_script, it returns /usr/bin/cmake
When I run ls /usr/bin | grep cmake in my terminal, it doesn't return anything. When I run brew info cmake it returns the version as cmake: stable 3.19.3
How do I update cmake in my runner? Apparently It can't find brew in the before_script either.
PS: added bonus, if I set the minimum cmake version required to 3.16 it suddenly seems to be unable to link libm
I forgot to add a tag. So it wasn't running on my computer but on a different server.

Need help completing command line installation of {fmt} on Windows 10

I'm a Linux user who's trying to set up a dev environment on Windows. I've cloned the fmt repo and built it the way I'm used to on Linux:
C:\Users\me\Development> git clone https://github.com/fmtlib/fmt.git
C:\Users\me\Development> cd fmt
C:\Users\me\Development> mkdir build
C:\Users\me\Development> cd build
C:\Users\me\Development> cmake ..
C:\Users\me\Development> cmake --build . --config Release
Now I want to install it so that I can include it in projects. Normally I would $ sudo make install but I'm not sure what to do on Windows and the fmt doc page has nothing for Windows installation.
When I did this same set of steps with FLTK there was a variable that I had to set to help me find things:
# CMakeLists.txt
set(FLTK_DIR "Path/to/installation")
find_package(FLTK REQUIRED NO_MODULE)
But it seems to be looking for the installation point, not the build dir. How can I get this to work?
You can run:
cmake --install . [--prefix <install-dir>]
The prefix is optional. On Windows, the default CMAKE_INSTALL_PREFIX is set to:
C:/Program Files (x86)/<project name>
Which in the case fmtlib would be:
C:/Program Files (x86)/FMT
Another option is to use vcpkg on Windows, which will install fmtlib locally in its own vcpkg install prefix. Then you can use it via:
find_package(fmt REQUIRED)
add_executable(myapp main.cpp)
target_link_libraries(myapp PRIVATE fmt::fmt)
You just have to pass the vcpkg cmake toolchain file to your cmake invocation:
cmake .. -DCMAKE_TOOLCHAIN_FILE=/path/to/vcpkg/scripts/buildsystems/vcpkg.cmake

make: *** No targets specified and no makefile found. Stop. [ubuntu]

I'm trying to build this
https://github.com/patrikhuber/eos
but I'm having troubles.
The instructions are pretty simple, as it says on gitHub
To build:
git clone --recursive https://github.com/patrikhuber/eos.git
mkdir build && cd build # creates a build directory next to the 'eos' folder
cmake -G "<your favourite generator>" ../eos -DCMAKE_INSTALL_PREFIX=../install/
make && make install # or open the project file and build in an IDE like Visual Studio
I'm using "Ninja" as generator and it looks like the cmake part goes through successfully as I get
-- Configuring done
-- Generating done
-- Build files have been written to: /home/francesco/eos/build
That's where things stop "working" for me, or where I fail to understand what's next. Following the instructions, I type
make && make install
and I get this message
make: *** No targets specified and no makefile found. Stop.
I looked around for solutions but I don't really understand what I am supposed to do: I tried
./configure
but I'm getting
bash: ./configure: No such file or directory
Anyone can please help?
Thanks
It always depends on your CMake "Generator". The 'make' is linux/mingw tool/command. For VisualStudio you can use nmake or sln/proj generated stuff.
More reliable could be utilize CMake for building i.e. for "NMake Makefiles" generator:
cmake --build <build folder> --target install
or
cmake --build <build folder> --config release --target install
for VisualStudio generator
I had the same problem, and solved by tinkering with locations for cmake and make. Here's what I used:
cmake -DCMAKE_INSTALL_PREFIX=/usr/local
make
I believe /usr/local is the default location (see here)

How to install CMake packages (configs) globally?

To be honest, I recently started working with find_package in CONFIG-mode... Is there an easy way to install packages globally on Windows 10?
Or I must manually set -DCMAKE_INSTALL_PREFIX and build all stuff by my hand?:
cmake . -Bbuild/debug -DCMAKE_BUILD_TYPE=Debug -DCMAKE_DEBUG_POSTFIX=d -DCMAKE_INSTALL_PREFIX="install"
cmake --build build/debug --target install
cmake . -Bbuild/release -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX="install"
cmake --build build/release --target install
All I want is - register the package once and forget about it. After the package is registered all commands like find_package(X CONFIG REQUIRED) must work well... Do all paths must be determined manually?

CMake compile -s -mt version of rabbitmq-c

I run cmake in command prompt with:
mkdir build && cd build
.. cmake
But now, I have problem constructing the command to build realease static.
I tried:
C:\Users\Kuba\Downloads\rabbitmq-c>cmake --build build --BUILD_STATIC_LIBS=ON
Which yields the error:
Unknown argument --BUILD_STATIC_LIBS=ON
How to correct this? Thanks !
You should define the variable using the -D option:
cmake --build build -DBUILD_STATIC_LIBS=ON
Please read the documentation for more information.
Configuring the build is a separate step from building it.
From the source directory create a binary directory:
mkdir build && cd build
Then configure the build (this is where you can add other build-flags):
cmake -DBUILD_STATIC_LIBS=ON ..
then build it:
cmake --build .