I am trying to use tesseract in a C++ application, but I can't get it to
run in Visual Studio. I am getting a couple of "error LNK2001: unresolved
external symbol", which I believe is because Visual Studio can't find the
dlls I am trying to use. I have done everything detailed at
http://stackoverflow.com/questions/14066074/using-tesseract-ocr-in-vc and
http://stackoverflow.com/questions/18180824/how-to-implement-tesseract-to-run-with-project-in-visual-studio-2010.
All the tesseract libraries are linked in the right places, but I still
can't get it to work. This is what my code looks like:
#include "stdafx.h"
#include <iostream>
#include <string>
#include <tesseract/baseapi.h>
#include <leptonica/allheaders.h>
using namespace std;
int main(int argc, char *argv[])
{
char *outText;
tesseract::TessBaseAPI *api = new tesseract::TessBaseAPI();
// Initialize tesseract-ocr with English, without specifying tessdata
path
if (api->Init(NULL, "eng")) {
fprintf(stderr, "Could not initialize tesseract.\n");
exit(1);
}
// Open input image with leptonica library
Pix *image =
pixRead("C:\\Users\\Marcio\\PythonProjects\\python_ocr.png");
api->SetImage(image);
// Get OCR result
outText = api->GetUTF8Text();
printf("OCR output:\n%s", outText);
// Destroy used object and release memory
api->End();
delete[] outText;
pixDestroy(&image);
return 0;
}
*This is the full error message I get:*
1>CallPythonFromC++.obj : error LNK2001: unresolved external symbol
"public: int __cdecl tesseract::TessBaseAPI::Init(char const *,char const
*,enum tesseract::OcrEngineMode,char * *,int,class GenericVector<class
STRING> const *,class GenericVector<class STRING> const *,bool)"
(?Init@TessBaseAPI@tesseract@@QEAAHPEBD0W4OcrEngineMode@2@PEAPEADHPEBV?$GenericVector@VSTRING@@@@3_N@Z)
1>CallPythonFromC++.obj : error LNK2001: unresolved external symbol
"public: __cdecl tesseract::TessBaseAPI::TessBaseAPI(void)"
(??0TessBaseAPI@tesseract@@QEAA@XZ)
1>CallPythonFromC++.obj : error LNK2001: unresolved external symbol pixRead
1>CallPythonFromC++.obj : error LNK2001: unresolved external symbol
"public: void __cdecl tesseract::TessBaseAPI::SetImage(struct Pix const *)"
(?SetImage@TessBaseAPI@tesseract@@QEAAXPEBUPix@@@Z)
1>CallPythonFromC++.obj : error LNK2001: unresolved external symbol
"public: char * __cdecl tesseract::TessBaseAPI::GetUTF8Text(void)"
(?GetUTF8Text@TessBaseAPI@tesseract@@QEAAPEADXZ)
1>CallPythonFromC++.obj : error LNK2001: unresolved external symbol
"public: void __cdecl tesseract::TessBaseAPI::End(void)"
(?End@TessBaseAPI@tesseract@@QEAAXXZ)
1>CallPythonFromC++.obj : error LNK2001: unresolved external symbol
pixDestroy
1>C:\Users\Marcio\BlindSight\CallPythonFromCPP\x64\Release\CallPythonFromC++.exe
: fatal error LNK1120: 7 unresolved externals
--
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 [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/tesseract-ocr.
To view this discussion on the web visit
https://groups.google.com/d/msgid/tesseract-ocr/ba300035-0bdc-4841-9d0d-36b4b1c85e12%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.