ChoiceIterator LNK2001

95 views
Skip to first unread message

Junmock Lee

unread,
Jun 27, 2016, 7:13:19 AM6/27/16
to tesseract-ocr
Hi all,

I'm trying API examples, but I couldn't build the example using ChoiceIterator because of linker errors.

Here is my code:
#include "stdafx.h"
#include "allheaders.h"
#include "baseapi.h"
#include <time.h>

using namespace std;
using namespace tesseract;

#pragma comment(lib, "liblept168")
#pragma comment(lib, "libtesseract302")
#pragma comment(lib, "winmm.lib")

int main(int argc, char* argv[])
{
 try
 
{
  
char *outText;
  
const char *path = "D:\\160614\\tesseract_testing\\test_texts\\tesseract_training\\";

  
TessBaseAPI *api = new TessBaseAPI();
  
if (api->Init(path, argv[2])) {
   fprintf
(stderr, "Could not initialize tesseract.\n");
   
exit(1);
  
}
 
  
Pix *image = pixRead(argv[1]);
  api
->SetImage(image);
  //Get OCR result
  outText = api->GetUTF8Text();
  printf
("OCR output:\n%s", outText);

  api
->SetImage(image);
  api
->SetVariable("save_blob_choices", "T");
  api
->SetRectangle(37, 228, 548, 31);
  api
->Recognize(NULL);

  tesseract
::ResultIterator* ri = api->GetIterator();
  tesseract
::PageIteratorLevel level = tesseract::RIL_SYMBOL;
  
if (ri != 0) {
   
do {
    
const char* symbol = ri->GetUTF8Text(level);
    
float conf = ri->Confidence(level);
    
if (symbol != 0) {
     printf
("symbol %s, conf: %f", symbol, conf);
     
bool indent = false;
     tesseract
::ChoiceIterator ci(*ri);
     
do {
      
if (indent) printf("\t\t ");
      printf
("\t- ");
      
const char* choice = ci.GetUTF8Text();
      printf
("%s conf: %f\n", choice, ci.Confidence());
      indent
= true;
     
} while (ci.Next());
    
}
    printf
("---------------------------------------------\n");
    
delete[] symbol;
   
} while ((ri->Next(level)));
  
}
 }
 
catch (...)
 
{
 printf
("error!");
 
}


 
return 0;
}

Build output:
1>Tesseract-ocr_tutorial_160607.obj : error LNK2001: unresolved external symbol "public: __thiscall tesseract::ChoiceIterator::ChoiceIterator(class tesseract::LTRResultIterator const &)" (??0ChoiceIterator@tesseract@@QAE@ABVLTRResultIterator@1@@Z)
1>Tesseract-ocr_tutorial_160607.obj : error LNK2001: unresolved external symbol "public: __thiscall tesseract::ChoiceIterator::~ChoiceIterator(void)" (??1ChoiceIterator@tesseract@@QAE@XZ)
1>Tesseract-ocr_tutorial_160607.obj : error LNK2001: unresolved external symbol "public: char const * __thiscall tesseract::ChoiceIterator::GetUTF8Text(void)const " (?GetUTF8Text@ChoiceIterator@tesseract@@QBEPBDXZ)
1>Tesseract-ocr_tutorial_160607.obj : error LNK2001: unresolved external symbol "public: float __thiscall tesseract::ChoiceIterator::Confidence(void)const " (?Confidence@ChoiceIterator@tesseract@@QBEMXZ)
1>Tesseract-ocr_tutorial_160607.obj : error LNK2001: unresolved external symbol "public: bool __thiscall tesseract::ChoiceIterator::Next(void)" (?Next@ChoiceIterator@tesseract@@QAE_NXZ)
1>C:\(my path)\Tesseract-ocr_tutorial_160607\Release\Tesseract-ocr_tutorial_160607.exe : fatal error LNK1120: 5 unresolved externals

I test one more code:
#include "stdafx.h"
#include "allheaders.h"
#include "baseapi.h"

using namespace std;
using namespace tesseract;

#pragma comment(lib, "liblept168")
#pragma comment(lib, "libtesseract302")

int main(int argc, char* argv[])
{
 tesseract
::ResultIterator* ri;
 tesseract
::ChoiceIterator ci(*ri);

 
return 0;
}

Build output:
1>Tesseract-ocr_tutorial_160607.obj : error LNK2001: unresolved external symbol "public: __thiscall tesseract::ChoiceIterator::ChoiceIterator(class tesseract::LTRResultIterator const &)" (??0ChoiceIterator@tesseract@@QAE@ABVLTRResultIterator@1@@Z)
1>Tesseract-ocr_tutorial_160607.obj : error LNK2001: unresolved external symbol "public: __thiscall tesseract::ChoiceIterator::~ChoiceIterator(void)" (??1ChoiceIterator@tesseract@@QAE@XZ)
1>C:\(my path)\Tesseract-ocr_tutorial_160607\Release\Tesseract-ocr_tutorial_160607.exe : fatal error LNK1120: 2 unresolved externals

Other classes are working fine, but ONLY ChoiceIterator is not working.
LTRResultIterator also can be built, although both LTRResultIterator and ChoiceIterator are defined in ltrresultiterator.h.
Do you have any suggestions?


Environment
Windows 7
Visual Studio 2013
Tesseract 3.02

Thanks,
Lee.

Junmock Lee

unread,
Jul 4, 2016, 6:31:05 AM7/4/16
to tesseract-ocr
According to this article, the ChoiceIterator is not included in the Tesseract 3.02 DLL.

It says "how to use tesseract-ocr API (v3.02.02) in C++" at API Examples Page, but it should be corrected.
Reply all
Reply to author
Forward
0 new messages