使用 C++ 将 tesseract API 的 TessBaseAPI 初始化为 api 指针给出错误

Initializing tesseract API's TessBaseAPI to api pointer with C++ giving error

我正在为 C++ 使用最新的 Tesseract API,并且我遵循了关于这个 post 的最后一个答案 link 什么是必要的。这些是我的包括:

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

当我尝试初始化 api 指针时:

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

它给了我以下相关的控制台错误(根本问题总共 56 个):

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

所以我的问题是,为什么会出错?我做错了什么?

我的怀疑: 某种 linking 错误,即使我按照 post 上的指南一步步进行。

我是 C++ 和 tesseract 的新手,任何见解都将不胜感激。

试试用VS2019编译吧。 Tesseract 的最新版本是使用 VS2019 构建的。

vcpkg提供了tesseract的静态库,使用起来比较麻烦。 构建共享库应该很容易。有很多教程,例如简约(tesseract 的一部分)https://bucket401.blogspot.com/2021/03/building-tesserocr-on-ms-windows-64bit.html 或更复杂 http://spell.linux.sk/building-tesseract-and-leptonica-with-cmake-and-clang-on-windows(你可以使用 VS 而不是 clang)