0

I am using the latest Tesseract API for C++ and I followed the last answer on this post to link what is necessary. These are my includes:

#include<iostream>
#include<Windows.h>
#include<opencv2/opencv.hpp>
#include<stdint.h>
#include<tesseract/baseapi.h>
#include<leptonica/allheaders.h>

When I try to initialize the api pointer with:

    tesseract::TessBaseAPI *api = new tesseract::TessBaseAPI();

it gives me the following relevant console errors (56 total from the root issue):

E1097   unknown attribute "no_init_all"
Warning C4101   'outText': unreferenced local variable
Error   LNK2001 unresolved external symbol __GSHandlerCheck_EH4 //this repeats for 52 of the errors
Error   LNK1120 1 unresolved externals

So my questions are, Why is it wrong? What am I doing wrong?

My Suspicions: Some sort of linking error, even though I followed the guide on post step by step.

I am fairly new to C++ and tesseract, any insight will be greatly appreciated.

4N0M41Y
  • 324
  • 1
  • 4
  • 12
  • _"Some sort of linking error ..."_ Definitiely a linking error, not only _sort of_ :-) Looks like a name mangling problem, try to wrap the corresponding library header `#include` into a `extern "C" { }` block. – πάντα ῥεῖ May 16 '21 at 18:51
  • I'm a noob, I apologize for the ignorance lol – 4N0M41Y May 16 '21 at 18:52
  • Ok so I wrapped all 4 variations of tesseract and leptonica, it gives me new errors: ```E1097 unknown attribute "no_init_all"``` ```E0800 this declaration may not have extern 'C' linkage``` ```E0338 more than one instance of overloaded function "tesseract::DeSerialize" has 'C' linkage``` ```C2733 'tesseract::DeSerialize': second C linkage of overloaded function not allowed``` etc. 149 errors – 4N0M41Y May 16 '21 at 19:00
  • This is how I am including them with extern c ```#include #include #include #include extern "C" { #include #include }``` – 4N0M41Y May 16 '21 at 19:05
  • Well, not all of these. Only the one containing `HandlerCheck` whereecer this comes from. – πάντα ῥεῖ May 16 '21 at 19:51
  • thank you for the answer back, but I tried all variations(1+2,1,2) for both libraries I added when it began to have these issues and the errors were that. I hope I didn't misunderstand your answer back – 4N0M41Y May 16 '21 at 20:19
  • 1
    Try running it on vs2019 – 4N0M41Y May 17 '21 at 02:34

2 Answers2

1

vcpkg provides static library of tesseract, which could be tricky to use. Building shared library should be easy. There are plenty tutorial e.g. minimalistic (tesseract part of) https://bucket401.blogspot.com/2021/03/building-tesserocr-on-ms-windows-64bit.html or more complex http://spell.linux.sk/building-tesseract-and-leptonica-with-cmake-and-clang-on-windows (you can use VS instead of clang)

user898678
  • 2,994
  • 2
  • 18
  • 17
0

Try compiling it with VS2019. The recent builds of Tesseract were built with VS2019.

4N0M41Y
  • 324
  • 1
  • 4
  • 12