Suggestions for Windows 10 x64 build issue

48 views
Skip to first unread message

CraigLandrum

unread,
Aug 18, 2023, 4:55:20 PM8/18/23
to tesseract-ocr
Our document scanning/document management app makes use of the tesseract library. We have a single .cpp the contains "glue" code to do things like clip areas of an image and adjust image depth and resolution before handling it off to SetImage and SetRectangle in tesseract.  In version 3.05 of tesseract, we did this by generating static versions of the leptonic and tesseract libraries and then linking them in a VS project with our glue code, creating a DLL that contains the linked glue code, tesseract lib, and leptonica lib with the tessdata folder in a zip file as a resource which is unpacked/unzipped at initialization.  This has worked like a champ from version 2.x through 3.05.  I'm now using VS 2022 on Windows 10 x64 and I've created the latest leptonica (1.83.1) and tesseract (5.3.1) as static libraries, but when I try and link with our glue code, I get a lot (908 to be exact) of LNK2005 and other weird errors.  The glue code is C++ and we are including tesseract's baseapi.h and a few other header files.  Has anyone else tried to do this on Windows 10 x64 and VS 2022? My Windows guru thinks it stems from including baseapi.h in both the glue code and the tesseract lib. Is there some obscure flag I can set in VS 2022 to tell it to ignore duplicately defined symbols (i.e. LNK2005)?  FYI, I did this successfully on a 64-bit Mac M1machine with no problem, so I suspect it is simply my ignorance of the VS 2022 options that is my issue on Windows.

Zdenko Podobny

unread,
Aug 20, 2023, 2:47:13 PM8/20/23
to tesser...@googlegroups.com
Maybe you should provide a simple test case for replicating the problem including information on how did you build tesseract&leptonica).

E.g. for SetRectangle_test.cpp (from https://groups.google.com/g/tesseract-ocr/c/PMHq6YSpRRE/m/Z2DCrgQlAAAJ) links without problem for me:

cl /EHsc SetRectangle_test.cpp /std:c++17 /I F:/win64/include /link /LIBPATH:F:\win64\lib leptonica-1.84.0.lib tesseract53.lib 
Microsoft (R) C/C++ Optimizing Compiler Version 19.29.30147 for x64
Copyright (C) Microsoft Corporation.  All rights reserved.

SetRectangle_test.cpp
Microsoft (R) Incremental Linker Version 14.29.30147.0
Copyright (C) Microsoft Corporation.  All rights reserved.

/out:SetRectangle_test.exe
/LIBPATH:F:\win64\lib
leptonica-1.84.0.lib
tesseract53.lib
SetRectangle_test.obj


Zdenko


pi 18. 8. 2023 o 22:55 CraigLandrum <cra...@mindwrap.com> napísal(a):
Our document scanning/document management app makes use of the tesseract library. We have a single .cpp the contains "glue" code to do things like clip areas of an image and adjust image depth and resolution before handling it off to SetImage and SetRectangle in tesseract.  In version 3.05 of tesseract, we did this by generating static versions of the leptonic and tesseract libraries and then linking them in a VS project with our glue code, creating a DLL that contains the linked glue code, tesseract lib, and leptonica lib with the tessdata folder in a zip file as a resource which is unpacked/unzipped at initialization.  This has worked like a champ from version 2.x through 3.05.  I'm now using VS 2022 on Windows 10 x64 and I've created the latest leptonica (1.83.1) and tesseract (5.3.1) as static libraries, but when I try and link with our glue code, I get a lot (908 to be exact) of LNK2005 and other weird errors.  The glue code is C++ and we are including tesseract's baseapi.h and a few other header files.  Has anyone else tried to do this on Windows 10 x64 and VS 2022? My Windows guru thinks it stems from including baseapi.h in both the glue code and the tesseract lib. Is there some obscure flag I can set in VS 2022 to tell it to ignore duplicately defined symbols (i.e. LNK2005)?  FYI, I did this successfully on a 64-bit Mac M1machine with no problem, so I suspect it is simply my ignorance of the VS 2022 options that is my issue on Windows.

--
You received this message because you are subscribed to the Google Groups "tesseract-ocr" group.
To unsubscribe from this group and stop receiving emails from it, send an email to tesseract-oc...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/tesseract-ocr/bf30d143-557c-4d3f-ab9a-22e4396fde2cn%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages