This should be easy, I am trying to add a new Console application to the Tesseract solution in VC++ 2008.
General problem: LNK2019 unresolved external symbol. Having difficulty with a new project in the Tesseract solution.
SOLVED:
A coworker in the know found the solution. I didn't list the tesseract*.lib in 'Linker > Input > Additional Dependencies'. Once they are added, it links fine.
MESSY DETAILS:
I followed http://tesseract-ocr.googlecode.com/svn/trunk/vs2008/doc/setup.html#using-the-latest-tesseractocr-sources and everything compiles fine, libraries get generated and all the rest. Proceeding this, I have tried to build my own project in the solution, following https://code.google.com/p/tesseract-ocr/wiki/APIExample. I used the first simple example:
#include <baseapi.h>
#include <leptonica/allheaders.h>
int main()
{
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("/usr/src/tesseract-3.02/phototest.tif");
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;
}
So I discovered I needed to add the additional directories, of course. So I copied all of the project settings from the Tesseract project settings. The problem now is I'm left with a bunch of LNK2019 errors. 'myTest.obj : error LNK2019: unresolved external symbol "public: void __thiscall tesseract::TessBaseAPI::End(void)" (?End@TessBaseAPI@tesseract@@QAEXXZ) referenced in function _main'. I have added the same Linker settings as the other projects that compile without issues.
In desperation, I made a replica of one of the other projects, dawg2wordlist. Every setting, all the code beyond unique naming, the directory of my new project is at the same level as the other Tesseract projects. How is it possible that with replicated settings and code that it isn't linking? What is the magic I am missing?
Thanks a lot!
Edit, someone asked for the settings. They are ripped directly from the other projects in the solution. They are as follows: Console application
C/C++ > Additional Include Directories: ..\..\api;..\..\ccmain;..\..\ccutil;..\..\ccstruct;..\..\classify;..\..\cube;..\..\cutil;..\..\dict;..\..\image;..\..\neural_networks\runtime;..\..\textord;..\..\viewer;..\..\wordrec;.;..\..\..\include;..\..\..\include\leptonica;..\port
C/C++ > Preprocessor Definitions: WIN32;_DEBUG;_CONSOLE;_WINDOWS;USE_STD_NAMESPACE;$(NOINHERIT)
Linker > General > Additional Library Directories: ..\..\..\lib
Linker > Input > Additional Dependencies: ws2_32.lib user32.lib zlib$(ZLIB_VERSION)-static-mtdll-debug.lib libpng$(LIBPNG_VERSION)-static-mtdll-debug.lib libjpeg$(LIBJPEG_VERSION)-static-mtdll-debug.lib giflib$(GIFLIB_VERSION)-static-mtdll-debug.lib libtiff$(LIBTIFF_VERSION)-static-mtdll-debug.lib liblept$(LIBLEPT_VERSION)-static-mtdll-debug.lib $(NOINHERIT)
Linker > System > SubSystem: Console (/SUBSYSTEM:CONSOLE)
Resources > General > Preprocessor Definitions: MYVERSION="$(LIBTESS_VERSION_R)"
They are all copied from the 'tesseract' project in the solution, along with the resource header, .rc files and main header file.