The test code snippet is textbook style:
if (tess.**Init**(nullptr, "eng")) { // (const char *datapath, const char *language)
cerr << "Tesseract initialization failed" << endl;
return -3;
}
The baseapi.h definition is:
int **Init**(const char *datapath, const char *language, OcrEngineMode mode,
char **configs, int configs_size,
const std::vector<std::string> *vars_vec,
const std::vector<std::string> *vars_values,
bool set_only_non_debug_params);
int Init(const char *datapath, const char *language, OcrEngineMode oem) {
return Init(datapath, language, oem, nullptr, 0, nullptr, nullptr, false);
}
int **Init**(const char *datapath, const char *language) {
return Init(datapath, language, OEM_DEFAULT, nullptr, 0, nullptr, nullptr,
false);
}
// In-memory version reads the traineddata file directly from the given
// data[data_size] array, and/or reads data via a FileReader.
int **Init**(const char *data, int data_size, const char *language,
OcrEngineMode mode, char **configs, int configs_size,
const std::vector<std::string> *vars_vec,
const std::vector<std::string> *vars_values,
bool set_only_non_debug_params, FileReader reader);
The Init call in my code appears to have the right parameters, and its call to another member Init also has the right parameters. But KDevelop reports the following error:
/home/reza/projects/kde/TextExtract/build> make -j8
[ 50%] Building CXX object CMakeFiles/TextExtract.dir/main.cpp.o
[100%] Linking CXX executable TextExtract
/usr/bin/ld: CMakeFiles/TextExtract.dir/main.cpp.o: in function `main':
/home/reza/projects/kde/TextExtract/main.cpp:47:(.text+0x29d): undefined reference to `tesseract::TessBaseAPI::TessBaseAPI()'
/usr/bin/ld: /home/reza/projects/kde/TextExtract/main.cpp:84:(.text+0x40a): undefined reference to `tesseract::TessBaseAPI::~TessBaseAPI()'
/usr/bin/ld: /home/reza/projects/kde/TextExtract/main.cpp:84:(.text+0x4fa): undefined reference to `tesseract::TessBaseAPI::~TessBaseAPI()'
/usr/bin/ld: CMakeFiles/TextExtract.dir/main.cpp.o: in function `tesseract::TessBaseAPI::Init(char const*, char const*)':
/usr/local/include/tesseract/baseapi.h:206:(.text._ZN9tesseract11TessBaseAPI4InitEPKcS2_[_ZN9tesseract11TessBaseAPI4InitEPKcS2_]+0x43): undefined reference to `tesseract::TessBaseAPI::Init(char const*, char const*, tesseract::OcrEngineMode, char**, int, std::vector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > > const*, std::vector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > > const*, bool)'
collect2: error: ld returned 1 exit status
make[2]: *** [CMakeFiles/TextExtract.dir/build.make:151: TextExtract] Error 1
make[1]: *** [CMakeFiles/Makefile2:83: CMakeFiles/TextExtract.dir/all] Error 2
make: *** [Makefile:136: all] Error 2
*** Failure: Exit code 2 ***
I’m a total newbie in KDevelop (and C++). I tried the following (from baseapi.h):
if (tess.**Init**(nullptr, "eng", OEM_DEFAULT,
nullptr,
0,
nullptr,
nullptr,
false)) {
and
if (tess.**Init**(nullptr, "eng", OEM_DEFAULT)) {
cerr << "Tesseract initialization failed" << endl;
return -3;
}
But these didn’t work either. What is the self-inflicted error here, please? Thanks.
Regards.