Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build Tesseract from source with Visual Studio #2876

Closed
essamzaky opened this issue Feb 2, 2020 · 115 comments
Closed

Build Tesseract from source with Visual Studio #2876

essamzaky opened this issue Feb 2, 2020 · 115 comments

Comments

@essamzaky
Copy link

essamzaky commented Feb 2, 2020


Environment

  • Tesseract Version: 5.0.0 alfa
  • Commit Number: a1a177f
  • Platform:Windows 10 64 bit

Current Behavior:

I can not build from source
i had download SW client and save it at "D:\Essam\Software\SW" the add to Path
and i can run SW in command line and see WS information as follow
D:\Tutorial\Git\tesseract\build>sw --version
sw.client.sw version 1.0.0
git revision 083bb99144549c1f361298e8284daa6b54422965
assembled on 30.01.2020 18:36:29 Egypt Standard Time

then i run the following commands to compile from source as describe in the following link
https://github.com/tesseract-ocr/tesseract/wiki/Compiling
the command are

git clone https://github.com/tesseract-ocr/tesseract tesseract
cd tesseract
mkdir build && cd build
cmake .. -G "Visual Studio 15 2017 Win64" -DCMAKE_INSTALL_PREFIX=inst

i receive the following error

"-- Selecting Windows SDK version 10.0.17763.0 to target Windows 10.0.18363.
Configuring tesseract version 5.0.0-alpha-621-ga1a17...
-- target changed from "auto" to "kaby-lake"
CMake Error at CMakeLists.txt:197 (find_package):
By not providing "FindSW.cmake" in CMAKE_MODULE_PATH this project has asked
CMake to find a package configuration file provided by "SW", but CMake did
not find one.

Could not find a package configuration file provided by "SW" with any of
the following names:

SWConfig.cmake
sw-config.cmake

Add the installation prefix of "SW" to CMAKE_PREFIX_PATH or set "SW_DIR" to
a directory containing one of the above files. If "SW" provides a separate
development package or SDK, be sure it has been installed.

-- Configuring incomplete, errors occurred!
See also "D:/Tutorial/Git/tesseract/build/CMakeFiles/CMakeOutput.log"."

the log file attached

CMakeOutput.log

Expected Behavior:

build tesseract solution

Suggested Fix:

@Moldoteck
Copy link

did you do :
sw setup
?

@essamzaky
Copy link
Author

essamzaky commented Feb 14, 2020

i did
sw setup
and repeated the steps
i still getting error as follow
command failed: exit code = 1120 (0x460)
sw command: D:/Essam/Software/SW/sw.exe -shared -platform x64 -d D:/Tutorial/Git/tesseract/build/.sw/cmake integrate -cmake-deps D:/Tutorial/Git/tesseract/build/.sw/cmake/sw.txt
CMake Error at C:/Users/essam.elkoshairy/.sw/storage/etc/sw/static/SWConfig.cmake:121 (message):
sw: non-zero exit code: 1
Call Stack (most recent call first):
CMakeLists.txt:213 (sw_execute)

@baishuangcheng
Copy link

I have the same mistake. After executing SW setup (at sw directory)and executing again cmake .. , the problem is solved.

@baishuangcheng
Copy link

I'm getting error as follow too:
Unpacking : [org.sw.demo.gnu.grep.gnulib-3.4.0]/[Source Archive] Exception in file D:/dev/cppan2/client2/src/sw/manager/storage.cpp:438, function get: Error downloading file for package: org.sw.demo.python.exe-3.8.1, file: Source Archive sw command: D:/OnonDev/sw.exe -shared -platform x86 -d D:/OnonDev/tesstutorial/tesseract/build/.sw/cmake integrate -cmake-deps D:/OnonDev/tesstutorial/tesseract/build/.sw/cmake/sw.txt CMake Error at C:/Users/33186/.sw/storage/etc/sw/static/SWConfig.cmake:121 (message): sw: non-zero exit code: 1 Call Stack (most recent call first): CMakeLists.txt:213 (sw_execute)

@essamzaky
Copy link
Author

may be there are cashed files from SW , if someone know how to clear SW cashed files from previous trials
or if someone know other solution please tell us

@Shreeshrii
Copy link
Collaborator

Appeyor build seems to use sw and is working. Check out the logs at https://ci.appveyor.com/project/zdenop/tesseract/build/job/c5l28ht5hq3x478q

@essamzaky
Copy link
Author

Sorry i do not know Appeyor , how i use it to generate Tesseract binaries , libs and headers , if there is any tutorial to use it please mention it

@Shreeshrii
Copy link
Collaborator

Appeyor is used for continuous integration for Tesseract - it automatically rebuilds tesseract after every commit (or however it is configured).

https://ci.appveyor.com/project/zdenop/tesseract/build/job/c5l28ht5hq3x478q/artifacts
has a zip file with all binaries and dlls from that build.

@Shreeshrii
Copy link
Collaborator

https://ci.appveyor.com/project/zdenop/tesseract/build/job/66l95n7ofxrs0xtf/artifacts
Environment: APPVEYOR_BUILD_WORKER_IMAGE=Visual Studio 2017, platform=Win64

@essamzaky
Copy link
Author

thanks @Shreeshrii i dwonloaded the following build
https://ci.appveyor.com/project/zdenop/tesseract/build/job/66l95n7ofxrs0xtf/artifacts
Environment: APPVEYOR_BUILD_WORKER_IMAGE=Visual Studio 2017, platform=Win64

But i found only the binaries , where i can find the hedears,lib and cmake folder ,
i'm trying to build OpenCV + Tesseract , Opencv needs tesseract headers , lib and cmake folder

i did this before by building tesseract on my machine and build install project which create all required folders and files
install folder contain the following folders (bin,cmake,include, and lib )

how i can get the required folders and files from Appeyor build version

@zdenop
Copy link
Contributor

zdenop commented Feb 15, 2020

If you try to build OpenCV + Tesseract, then try to follow blog Building tesseract and leptonica with CMake and Clang on Windows - you do not need most of tesseract dependencies / or you already build it as OpenCV.

@essamzaky
Copy link
Author

essamzaky commented Feb 15, 2020

I succeed to build Tesseract from source by doing the following
1-Clear the cashed files by SW from old trials you can find the files in "C:\Users\yourUserName\.sw"
2-Delete the old cloned tesseract
3-install latest SW client and add it to path
4-Open command line cmd and run as administrator --> not mentioned in wiki
5-in cmd run sw setup --> not mentioned in wiki
6-change directory where you want clone tesseract source cd D:\Tutorial\Git
7-clone tesseract and build tesseract
git clone https://github.com/tesseract-ocr/tesseract tesseract
cd tesseract
mkdir build && cd build
cmake .. -G "Visual Studio 15 2017 Win64" -DCMAKE_INSTALL_PREFIX=inst
8-Open the tesseract solution you will find it in ""D:\Tutorial\Git\tesseract\build\tesseract.sln""
9-Build the solution in VS
Note
Debug version succeded
Release version failed due to adding some debug libraries in Release
the debug libraries are
concrtd.lib
msvcprtd.lib
vcruntimed.lib
msvcrtd.lib
ucrtd.lib
Change them to release by removing the letter "d"
concrt.lib
msvcprt.lib
vcruntime.lib
msvcrt.lib
ucrt.lib
then the Release version will build successfully

Also succeded to build OpenCV with Tesseract

@essamzaky
Copy link
Author

If you try to build OpenCV + Tesseract, then try to follow blog Building tesseract and leptonica with CMake and Clang on Windows - you do not need most of tesseract dependencies / or you already build it as OpenCV.

Thanks @zdenop i will try this plog , actually a followed many tutorials but failed to build latest tesseract + OpenCV

@baishuangcheng
Copy link

@essamzaky I try your plog,but get this error:

D:\OnonDev\tesstutorial\libsrc\zlib-1.2.11\build.clang>set CC=clang-cl

D:\OnonDev\tesstutorial\libsrc\zlib-1.2.11\build.clang>set CXX=clang-cl

D:\OnonDev\tesstutorial\libsrc\zlib-1.2.11\build.clang>cmake .. -G Ninja -DCMAKE_INSTALL_PREFIX=%INSTALL_DIR% -DCMAKE_BUILD_TYPE=Release
CMake Error at C:/Program Files (x86)/Microsoft Visual Studio/2017/Enterprise/Common7/IDE/CommonExtensions/Microsoft/CMake/CMake/share/cmake-3.12/Modules/CMakeDetermineCCompiler.cmake:48 (message):
  Could not find compiler set in environment variable CC:

  clang-cl.
Call Stack (most recent call first):
  CMakeLists.txt:4 (project)


CMake Error: CMAKE_C_COMPILER not set, after EnableLanguage
-- Configuring incomplete, errors occurred!
See also "D:/OnonDev/tesstutorial/libsrc/zlib-1.2.11/build.clang/CMakeFiles/CMakeOutput.log".

@baishuangcheng
Copy link

copy
C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\VC\Tools\ClangC2\14.10.25903\bin\HostX64\clang.exe
and rename to clang-cl.exe
it is work.

@zdenop
Copy link
Contributor

zdenop commented Feb 16, 2020

set CC=clang should be sufficient.
But it is stupid that they used name clang.exe (gcc compatibility mode) instead of clang-cl.exe (VS compatibility mode)

@korhun
Copy link

korhun commented Feb 17, 2020

I succeed to build Tesseract from source by doing the following
1-Clear the cashed files by SW from old trials you can find the files in "C:\Users\yourUserName.sw"
2-Delete the old cloned tesseract
3-install latest SW client and add it to path
4-Open command line cmd and run as administrator --> not mentioned in wiki
5-in cmd run sw setup --> not mentioned in wiki
6-change directory where you want clone tesseract source cd D:\Tutorial\Git
7-clone tesseract and build tesseract
git clone https://github.com/tesseract-ocr/tesseract tesseract
cd tesseract
mkdir build && cd build
cmake .. -G "Visual Studio 15 2017 Win64" -DCMAKE_INSTALL_PREFIX=inst
8-Open the tesseract solution you will find it in ""D:\Tutorial\Git\tesseract\build\tesseract.sln""
9-Build the solution in VS
Note
Debug version succeded
Release version failed due to adding some debug libraries in Release
the debug libraries are
concrtd.lib
msvcprtd.lib
vcruntimed.lib
msvcrtd.lib
ucrtd.lib
Change them to release by removing the letter "d"
concrt.lib
msvcprt.lib
vcruntime.lib
msvcrt.lib
ucrt.lib
then the Release version will build successfully

Also succeded to build OpenCV with Tesseract

@essamzaky this information you have provided saved a lot of time :) thank you very much...

For Visual Studio 2019 this works:
cmake .. -G "Visual Studio 16 2019" -A x64 -DCMAKE_INSTALL_PREFIX=inst

@essamzaky
Copy link
Author

I succeed to build Tesseract from source by doing the following
1-Clear the cashed files by SW from old trials you can find the files in "C:\Users\yourUserName.sw"
2-Delete the old cloned tesseract
3-install latest SW client and add it to path
4-Open command line cmd and run as administrator --> not mentioned in wiki
5-in cmd run sw setup --> not mentioned in wiki
6-change directory where you want clone tesseract source cd D:\Tutorial\Git
7-clone tesseract and build tesseract
git clone https://github.com/tesseract-ocr/tesseract tesseract
cd tesseract
mkdir build && cd build
cmake .. -G "Visual Studio 15 2017 Win64" -DCMAKE_INSTALL_PREFIX=inst
8-Open the tesseract solution you will find it in ""D:\Tutorial\Git\tesseract\build\tesseract.sln""
9-Build the solution in VS
Note
Debug version succeded
Release version failed due to adding some debug libraries in Release
the debug libraries are
concrtd.lib
msvcprtd.lib
vcruntimed.lib
msvcrtd.lib
ucrtd.lib
Change them to release by removing the letter "d"
concrt.lib
msvcprt.lib
vcruntime.lib
msvcrt.lib
ucrt.lib
then the Release version will build successfully
Also succeded to build OpenCV with Tesseract

@essamzaky this information you have provided saved a lot of time :) thank you very much...

For Visual Studio 2019 this works:
cmake .. -G "Visual Studio 16 2019" -A x64 -DCMAKE_INSTALL_PREFIX=inst

Good to know it helped you :) , Building Tesseract + Opencv in windows was like nightmare for me , from 4 month ago it took 2 weeks from me without any success , someone from Opencv contributors helped me with some workarounds ,
anyway good luck.

@essamzaky
Copy link
Author

Hints about cloning and install paths
it's seems cmake cannot process the *.cmake file generated by tesseract correctly see the following issue
#2883
1-use small letters in the cloning path , and install path
i.e "D:\Tesseract" for cloning may cause problem replace it by "d:\tesseract" , '\T' is the reason
2-do not use special characters in the cloning path
i.e "d:\my tesseract " my cause problem so replace it by "d:\mytess" space my be the source of error
3-do not use very long folders names
i.e "d:\My Tesseract Build" do not exceed 8 characters replace it by "d:\mytess"

@moni179
Copy link

moni179 commented Feb 17, 2020

I succeed to build Tesseract from source by doing the following
1-Clear the cashed files by SW from old trials you can find the files in "C:\Users\yourUserName.sw"
2-Delete the old cloned tesseract
3-install latest SW client and add it to path
4-Open command line cmd and run as administrator --> not mentioned in wiki
5-in cmd run sw setup --> not mentioned in wiki
6-change directory where you want clone tesseract source cd D:\Tutorial\Git
7-clone tesseract and build tesseract
git clone https://github.com/tesseract-ocr/tesseract tesseract
cd tesseract
mkdir build && cd build
cmake .. -G "Visual Studio 15 2017 Win64" -DCMAKE_INSTALL_PREFIX=inst
8-Open the tesseract solution you will find it in ""D:\Tutorial\Git\tesseract\build\tesseract.sln""
9-Build the solution in VS
Note
Debug version succeded
Release version failed due to adding some debug libraries in Release
the debug libraries are
concrtd.lib
msvcprtd.lib
vcruntimed.lib
msvcrtd.lib
ucrtd.lib
Change them to release by removing the letter "d"
concrt.lib
msvcprt.lib
vcruntime.lib
msvcrt.lib
ucrt.lib
then the Release version will build successfully

Also succeded to build OpenCV with Tesseract
@essamzaky
I followed this instructions like 4 times and i still having the same error that you had:
command failed: exit code = 1120 (0x460)
sw command: D:/Essam/Software/SW/sw.exe -shared -platform x64 -d D:/Tutorial/Git/tesseract/build/.sw/cmake integrate -cmake-deps D:/Tutorial/Git/tesseract/build/.sw/cmake/sw.txt
CMake Error at C:/Users/essam.elkoshairy/.sw/storage/etc/sw/static/SWConfig.cmake:121 (message):
sw: non-zero exit code: 1
Call Stack (most recent call first):
CMakeLists.txt:213 (sw_execute)
Any idea?

@essamzaky
Copy link
Author

essamzaky commented Feb 17, 2020

I succeed to build Tesseract from source by doing the following
1-Clear the cashed files by SW from old trials you can find the files in "C:\Users\yourUserName.sw"
2-Delete the old cloned tesseract
3-install latest SW client and add it to path
4-Open command line cmd and run as administrator --> not mentioned in wiki
5-in cmd run sw setup --> not mentioned in wiki
6-change directory where you want clone tesseract source cd D:\Tutorial\Git
7-clone tesseract and build tesseract
git clone https://github.com/tesseract-ocr/tesseract tesseract
cd tesseract
mkdir build && cd build
cmake .. -G "Visual Studio 15 2017 Win64" -DCMAKE_INSTALL_PREFIX=inst
8-Open the tesseract solution you will find it in ""D:\Tutorial\Git\tesseract\build\tesseract.sln""
9-Build the solution in VS
Note
Debug version succeded
Release version failed due to adding some debug libraries in Release
the debug libraries are
concrtd.lib
msvcprtd.lib
vcruntimed.lib
msvcrtd.lib
ucrtd.lib
Change them to release by removing the letter "d"
concrt.lib
msvcprt.lib
vcruntime.lib
msvcrt.lib
ucrt.lib
then the Release version will build successfully
Also succeded to build OpenCV with Tesseract
@essamzaky
I followed this instructions like 4 times and i still having the same error that you had:
command failed: exit code = 1120 (0x460)
sw command: D:/Essam/Software/SW/sw.exe -shared -platform x64 -d D:/Tutorial/Git/tesseract/build/.sw/cmake integrate -cmake-deps D:/Tutorial/Git/tesseract/build/.sw/cmake/sw.txt
CMake Error at C:/Users/essam.elkoshairy/.sw/storage/etc/sw/static/SWConfig.cmake:121 (message):
sw: non-zero exit code: 1
Call Stack (most recent call first):
CMakeLists.txt:213 (sw_execute)
Any idea?

@moni179
try to post the error in your machine , and if you can attach log file may be this leads to discover the error

@moni179
Copy link

moni179 commented Feb 18, 2020

@essamzaky
This is the error:
Exception in file D:/dev/cppan2/client2/src/sw/builder/command.cpp:592, function execute1: When executing: D:/tutorialgit/tesseract/build/.sw/cmake/.sw/cfg/162151/loc.sw.self.b2da42-local.dll
Creando biblioteca D:/tutorialgit/tesseract/build/.sw/cmake/.sw/cfg/162151/loc.sw.self.b2da42-local.lib y objeto D:/tutorialgit/tesseract/build/.sw/cmake/.sw/cfg/162151/loc.sw.self.b2da42-local.exp
sw.cpp.a2a6fd.8626daaf.obj : error LNK2001: sÝmbolo externo "protected: virtual bool __cdecl sw::NativeCompiledTarget::isStaticLibrary(void)const " (?isStaticLibrary@NativeCompiledTarget@sw@@MEBA_NXZ) sin resolver
sw.cpp.a2a6fd.e466861e.obj : error LNK2001: sÝmbolo externo "protected: virtual bool __cdecl sw::NativeCompiledTarget::isStaticLibrary(void)const " (?isStaticLibrary@NativeCompiledTarget@sw@@MEBA_NXZ) sin resolver
sw.cpp.a2a6fd.b2799dc2.obj : error LNK2001: sÝmbolo externo "protected: virtual bool __cdecl sw::NativeCompiledTarget::isStaticLibrary(void)const " (?isStaticLibrary@NativeCompiledTarget@sw@@MEBA_NXZ) sin resolver
sw.cpp.a2a6fd.a02e449b.obj : error LNK2001: sÝmbolo externo "protected: virtual bool __cdecl sw::NativeCompiledTarget::isStaticLibrary(void)const " (?isStaticLibrary@NativeCompiledTarget@sw@@MEBA_NXZ) sin resolver
D:\tutorialgit\tesseract\build.sw\cmake.sw\cfg\162151\loc.sw.self.b2da42-local.dll : fatal error LNK1120: 1 externos sin resolver
command failed: exit code = 1120 (0x460)
sw command: C:/Program Files/Tesseract-OCR/sw.exe -shared -platform x64 -d D:/tutorialgit/tesseract/build/.sw/cmake integrate -cmake-deps D:/tutorialgit/tesseract/build/.sw/cmake/sw.txt
CMake Error at C:/Users/monil/.sw/storage/etc/sw/static/SWConfig.cmake:121 (message):
sw: non-zero exit code: 1
Call Stack (most recent call first):
CMakeLists.txt:213 (sw_execute)

-- Configuring incomplete, errors occurred!
See also "D:/tutorialgit/tesseract/build/CMakeFiles/CMakeOutput.log".

CMakeOutput.log

@essamzaky
Copy link
Author

@essamzaky
This is the error:
Exception in file D:/dev/cppan2/client2/src/sw/builder/command.cpp:592, function execute1: When executing: D:/tutorialgit/tesseract/build/.sw/cmake/.sw/cfg/162151/loc.sw.self.b2da42-local.dll
Creando biblioteca D:/tutorialgit/tesseract/build/.sw/cmake/.sw/cfg/162151/loc.sw.self.b2da42-local.lib y objeto D:/tutorialgit/tesseract/build/.sw/cmake/.sw/cfg/162151/loc.sw.self.b2da42-local.exp
sw.cpp.a2a6fd.8626daaf.obj : error LNK2001: sÝmbolo externo "protected: virtual bool __cdecl sw::NativeCompiledTarget::isStaticLibrary(void)const " (?isStaticLibrary@NativeCompiledTarget@sw@@MEBA_NXZ) sin resolver
sw.cpp.a2a6fd.e466861e.obj : error LNK2001: sÝmbolo externo "protected: virtual bool __cdecl sw::NativeCompiledTarget::isStaticLibrary(void)const " (?isStaticLibrary@NativeCompiledTarget@sw@@MEBA_NXZ) sin resolver
sw.cpp.a2a6fd.b2799dc2.obj : error LNK2001: sÝmbolo externo "protected: virtual bool __cdecl sw::NativeCompiledTarget::isStaticLibrary(void)const " (?isStaticLibrary@NativeCompiledTarget@sw@@MEBA_NXZ) sin resolver
sw.cpp.a2a6fd.a02e449b.obj : error LNK2001: sÝmbolo externo "protected: virtual bool __cdecl sw::NativeCompiledTarget::isStaticLibrary(void)const " (?isStaticLibrary@NativeCompiledTarget@sw@@MEBA_NXZ) sin resolver
D:\tutorialgit\tesseract\build.sw\cmake.sw\cfg\162151\loc.sw.self.b2da42-local.dll : fatal error LNK1120: 1 externos sin resolver
command failed: exit code = 1120 (0x460)
sw command: C:/Program Files/Tesseract-OCR/sw.exe -shared -platform x64 -d D:/tutorialgit/tesseract/build/.sw/cmake integrate -cmake-deps D:/tutorialgit/tesseract/build/.sw/cmake/sw.txt
CMake Error at C:/Users/monil/.sw/storage/etc/sw/static/SWConfig.cmake:121 (message):
sw: non-zero exit code: 1
Call Stack (most recent call first):
CMakeLists.txt:213 (sw_execute)

-- Configuring incomplete, errors occurred!
See also "D:/tutorialgit/tesseract/build/CMakeFiles/CMakeOutput.log".

CMakeOutput.log

Hi @egorpugin do you know the reason for the described error

@egorpugin
Copy link
Contributor

egorpugin commented Feb 18, 2020

Hi,

@essamzaky
Try to run sw --self-upgrade then sw setup and re-run cmake.
There are lots of messages here, please point me at specific issues, so I could help.

As for opencv+tess - check out this example using sw (main file is near to cmake lists)
https://github.com/SoftwareNetwork/sw/blob/master/test/integrations/cmake/tess/CMakeLists.txt

@essamzaky
Copy link
Author

@moni179 describe the steps you applied and the error details
then link egorpugin to the post he will help you

@jasnei
Copy link

jasnei commented Feb 23, 2020

@essamzaky @egorpugin
I tried many many times as you post. I tried many days, again & again.
But I still got these Error, fail to debug.

Here is the Error.
glib-enumtypes.h is not in the directory, but there is glib-enumtypes.h.template.
I had chang it to glib-enumtypes.h, but still not ok.
Could anyone help me out? Thank you.

Error MSB6006 “cmd.exe”exit,code 1. BUILD_DEPENDENCIES C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\IDE\VC\VCTargets C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\IDE\VC\VCTargets\Microsoft.CppCommon.targets
Error LNK1104 Cannot open file“C:\Users\Administrator.sw\storage\pkg\75\6a\600e\obj\bld\471767\lib\org.sw.demo.danbloomberg.leptonica-1.80.0.lib” libtesseract D:\gittess\tesseract2\build D:\gittess\tesseract2\build\LINK
Error LNK1104 Cannot open file“....\Debug\tesseract50d.lib” ambiguous_words D:\gittess\tesseract2\build\src\training D:\gittess\tesseract2\build\src\training\LINK
Error LNK1104 Cannot open file“....\Debug\tesseract50d.lib” combine_tessdata D:\gittess\tesseract2\build\src\training D:\gittess\tesseract2\build\src\training\LINK
Error LNK1104 Cannot open file“....\Debug\tesseract50d.lib” dawg2wordlist D:\gittess\tesseract2\build\src\training D:\gittess\tesseract2\build\src\training\LINK
Error LNK1104 Cannot open file“....\Debug\tesseract50d.lib” classifier_tester D:\gittess\tesseract2\build\src\training D:\gittess\tesseract2\build\src\training\LINK
Error LNK1104 Cannot open file“....\Debug\tesseract50d.lib” cntraining D:\gittess\tesseract2\build\src\training D:\gittess\tesseract2\build\src\training\LINK
Error LNK1104 Cannot open file“....\Debug\tesseract50d.lib” combine_lang_model D:\gittess\tesseract2\build\src\training D:\gittess\tesseract2\build\src\training\LINK
Error LNK1104 Cannot open file“....\Debug\tesseract50d.lib” lstmeval D:\gittess\tesseract2\build\src\training D:\gittess\tesseract2\build\src\training\LINK
Error LNK1104 Cannot open file“....\Debug\tesseract50d.lib” mftraining D:\gittess\tesseract2\build\src\training D:\gittess\tesseract2\build\src\training\LINK
Error LNK1104 Cannot open file“....\Debug\tesseract50d.lib” lstmtraining D:\gittess\tesseract2\build\src\training D:\gittess\tesseract2\build\src\training\LINK
Error LNK1104 Cannot open file“....\Debug\tesseract50d.lib” set_unicharset_properties D:\gittess\tesseract2\build\src\training D:\gittess\tesseract2\build\src\training\LINK
Error C1083 Unable to open include file: “gobject/glib-enumtypes.h”: No such file or directory (Compile source file D:\gittess\tesseract2\src\training\text2image.cpp) text2image C:\Users\Administrator.sw\storage\pkg\b8\f1\524a\src\sdir\glib C:\Users\Administrator.sw\storage\pkg\b8\f1\524a\src\sdir\glib\glib-object.h
Error LNK1104 Cannot open file“Debug\tesseract50d.lib” tesseract D:\gittess\tesseract2\build D:\gittess\tesseract2\build\LINK
Error C1083 Unable to open include file: “gobject/glib-enumtypes.h”: No such file or directory (Compile source file D:\gittess\tesseract2\src\training\ligature_table.cpp) text2image C:\Users\Administrator.sw\storage\pkg\b8\f1\524a\src\sdir\glib C:\Users\Administrator.sw\storage\pkg\b8\f1\524a\src\sdir\glib\glib-object.h
Error C1083 Unable to open include file: “gobject/glib-enumtypes.h”: No such file or directory (Compile source file D:\gittess\tesseract2\src\training\pango_font_info.cpp) text2image C:\Users\Administrator.sw\storage\pkg\b8\f1\524a\src\sdir\glib C:\Users\Administrator.sw\storage\pkg\b8\f1\524a\src\sdir\glib\glib-object.h
Error C1083 Unable to open include file: “gobject/glib-enumtypes.h”: No such file or directory (Compile source file D:\gittess\tesseract2\src\training\stringrenderer.cpp) text2image C:\Users\Administrator.sw\storage\pkg\b8\f1\524a\src\sdir\glib C:\Users\Administrator.sw\storage\pkg\b8\f1\524a\src\sdir\glib\glib-object.h
Error LNK1104 Cannot open file“....\Debug\tesseract50d.lib” unicharset_extractor D:\gittess\tesseract2\build\src\training D:\gittess\tesseract2\build\src\training\LINK
Error LNK1104 Cannot open file“....\Debug\tesseract50d.lib” wordlist2dawg D:\gittess\tesseract2\build\src\training D:\gittess\tesseract2\build\src\training\LINK

@egorpugin
Copy link
Contributor

@jasnei
Please, provide more info.
How do you invoke build?
What do you do?
What do you want? Use tesseract in your application?

@jasnei
Copy link

jasnei commented Feb 23, 2020

@egorpugin

Environment

  • Tesseract Version: 5.0.0 alfa
  • Platform:Windows 7 64 bit

What I did

  • I succeed to build Tesseract from source by doing the following
  • 1-Clear the cashed files by SW from old trials you can find the files in "C:\Users\yourUserName.sw"
  • 2-Delete the old cloned tesseract
  • 3-install latest SW client and add it to path
  • 4-Open command line cmd and run as administrator --> not mentioned in wiki
  • 5-in cmd run sw setup --> not mentioned in wiki
  • 6-change directory where you want clone tesseract source cd D:\Tutorial\Git
  • 7-clone tesseract and build tesseract
  • git clone https://github.com/tesseract-ocr/tesseract tesseract
  • cd tesseract
  • mkdir build && cd build
  • cmake .. -G "Visual Studio 15 2017 Win64" -DCMAKE_INSTALL_PREFIX=inst
  • 8-Open the tesseract solution you will find it in ""D:\Tutorial\Git\tesseract\build\tesseract.sln""
  • 9-Build the solution in VS

What I want
I want use tesseract for OpenCV.

Thanks

@egorpugin
Copy link
Contributor

I want use tesseract for OpenCV.

What does it mean?

@jasnei
Copy link

jasnei commented Feb 24, 2020

@egorpugin

What I mean I'm using OpenCV with vs2017, I would like to build tesseract so that I can use it in vs2017.

@egorpugin
Copy link
Contributor

That's better. We have progress.
Try this.

sw.client.sw-1.0.0.exe.zip

@BJungmann
Copy link

trace20210125_15.33.txt

No difference if I use -platform x86 (only reported build id is different)

@egorpugin
Copy link
Contributor

egorpugin commented Jan 25, 2021

Ok, please do following:

  1. Create 1.cpp, add #include <iostream> to it.
  2. In VS command prompt run cl /c /showIncludes 1.cpp, post output.
  3. Try step 2 in normal command prompt running "c:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin\cl.exe /c /showIncludes 1.cpp", post output.

@BJungmann
Copy link

I did step 2 first in simple cmd window, then called vcvarsall.bat, then did it again.
trace20210125_16.10.txt

Here the output of doing it in VS command prompt:
trace20210125_16.23VSCommandPrompt.txt

@egorpugin
Copy link
Contributor

Try without -platform x86.
sw.client.sw-1.0.0.exe.zip

@BJungmann
Copy link

Much better - there was a lot of traffic in the cmd window. 1179 *.obj files were generated in .sw\t subdirectories, no *.dll, no *.lib, no *.exe.

I attach the tail of the cmd window output, which seemed to me as no longer checking my environment, but trying to do real work (?).
trace20210125_17.10.txt

@egorpugin
Copy link
Contributor

egorpugin commented Jan 25, 2021

Ok, now it sees your compiler.
Next issue is that sw itself requires VS2019 (or lightweight VS2019 Build tools, 200-400 MB) to be installed.
Is it possible to install any of these?

@BJungmann
Copy link

I'm installing a package that is advertized as 9.7 GB. Thank goodness, I needed a new computer in the beginning of 2020 ;-)

@egorpugin
Copy link
Contributor

For reference - VS Build Tools https://aka.ms/buildtools

@BJungmann
Copy link

BJungmann commented Jan 25, 2021

Now sw --trace build ... seems to have worked as it should. No occurrence of "error" in output. Last two lines:
build step 6 time: 114.544 s.
void __cdecl sw::SwBuild::build(void) time: 283.995 s.

What am I to do next? Where can I find generated executables and libraries?

@egorpugin
Copy link
Contributor

egorpugin commented Jan 25, 2021

They are stored in sw storage (c:\users\u\.sw\storage\pkg).
To find specific library dir, you should call sw open yourtargetname (what target your write in build command).
Or you can try to run sw setup to register sw uri handlers in system and open those dirs from browser (https://software-network.org/org.sw.demo.google.tesseract.libtesseract-master/actions - Open Build dir button).
But it's hard to copy everything by hand.

How do you want to use those libraries?

Sw support cmake as integration target.
To integrate with it see this example https://github.com/SoftwareNetwork/sw/blob/master/test/integrations/cmake/tess/CMakeLists.txt#L13

@BJungmann
Copy link

cmake .. was the magic word I was still missing. Now I see tesseract.sln, libtesseract.vxproj and some other .vxproj files, and I can open them into VS2015 Express GUI.

Thank you very much!!

@BJungmann
Copy link

Sorry to call up again: Now the real compilation for libtesseract is going inside VS, I am getting
tesseract\src\ccutil\params.h(208): error C2512: "tesseract::STRING": Kein geeigneter Standardkonstruktor verfügbar tesseract\src\ccutil\strngs.h(35): note: Siehe Deklaration von "tesseract::STRING"
(no proper standard constructor available, see declaration). File strngs.h has been moved recently, so this question may be better addressed to @stweil?

@stweil
Copy link
Member

stweil commented Jan 25, 2021

This looks like missing support for C++-17. It's the same error which was reported in issue #3255.

@egorpugin
Copy link
Contributor

@BJungmann

We are upgrading C++ standard in tess, so for master branch you should use the latest VS2019 (or at least VS2017, not sure if it works).
Older branches (3.* and 4.*) should work on VS2015.

@BJungmann
Copy link

Now I succeded using the generated libtesseract.vcxproj with VS2019 to make static Debug/libtesseract50d.lib for Win32/x86. And I could link it with my Qt-Project which is generated with VS2015. And I could run it and even debug into the tesseract sources, and the OCR results were OK.
But the corresponding Release version did link and run as well, but the OCR results were different and much worse. So I found issue #1223 and set the /Od flag in VS. This fixed the OCR result problem in release mode.

@stweil
Copy link
Member

stweil commented Jan 29, 2021

@BJungmann, /Oddisables optimization as far as I remember, so that might be unwanted. I'd try /Os or /O1.

@BJungmann
Copy link

Indeed in #1223 /O1 was suggested. But now I tested /O1 and /Ox, which were offered in the VS options, and both rendered bad OCR results. Back to /Od, and the results were good.
I have made no effort yet to find the reasons for that.

@stweil stweil changed the title Build Tesseract from source for windows Build Tesseract from source with Visual Studio Feb 1, 2021
@amitdo
Copy link
Collaborator

amitdo commented Feb 2, 2021

@BJungmann

Please don't mix two different issues in the same place. Open a new issue for the VS 2019 issue.

@BJungmann
Copy link

@amitdo, which different issues do you mean? Do you think the poor recognition result on x86 platform with optimization activated is worth a new issue?

@egorpugin, is there a recommended way to access leptonica functions directly from my own code? I see no leptonica allheaders.h in the installed tesseract bundle, but I find it hidden in .sw/storage/pkg...., so it should be possible somehow.

@egorpugin
Copy link
Contributor

Does #include <allheaders.h> work?

@BJungmann
Copy link

I want to do it in a Qt Creator project, with no CMake support yet, so I specify the include search pathes manually. I can access an older allheaders.h from leptonica-1.78, but I want to access the same leptonica instance that was used in tesseract50.lib. I don't know how to access the magic in finding things in .se/storage/pkg.

@BJungmann
Copy link

I tried to run
sw build org.sw.demo.danbloomberg.leptonica
in leptonica (from https://github.com/DanBloomberg/leptonica.git/tags/1.80.0) build dir, and with cmake and VS 2019 created and installed leptonica in c:\Program Files (x86). But if I link to that instance, openjpeg was lacking. So I got it (from c:\Program Files (x86)), and still GIF and WebP functions are lacking. I am going to find and compile them.
But this procedure seems to be not necessary if the dependencies are managed by sw.

@amitdo
Copy link
Collaborator

amitdo commented Feb 3, 2021

Do you think the poor recognition result on x86 platform with optimization activated is worth a new issue?

Yes.

@BJungmann
Copy link

I have now opened the new issue #3283.

@zdenop
Copy link
Contributor

zdenop commented Sep 16, 2021

Closing this as original post was about compiling from source on windows, which is solved.

@zdenop zdenop closed this as completed Sep 16, 2021
@ZhangDonglin12
Copy link

-- sw: processing dependencies
Downloading: [org.sw.demo.preshing.junction-master]/[Source Archive]
Exception in file D:/dev/cppan2/client2/src/sw/manager/storage.cpp:353, function get: Error downloading file for package: org.sw.demo.preshing.junction-master, file: Source Archive
sw command: C:/Program Files/SW/sw.exe -static -platform x86 -compiler msvc-19.16 -d D:/VSWorkSpace/tesseract-5.1.0/build/.sw/cmake -config d,msr,rwdi,r integrate -cmake-deps D:/VSWorkSpace/tesseract-5.1.0/build/.sw/cmake/sw.txt -cmake-file-version 6
CMake Error at C:/Users/zdl25/.sw/storage/etc/sw/static/SWConfig.cmake:235 (message):
sw: non-zero exit code: 1
Call Stack (most recent call first):
CMakeLists.txt:355 (sw_execute)

I got the error repor when downloading org.sw.demo.preshing.junction-master ,how can I solve the problem?
CMakeError.log
CMakeOutput.log
t

@padash00
Copy link

I can't write 'sw setup,' and what is this 'sw' folder?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests