When promoting shared libraries with LDFLAGS="-Wl,--no-undefined", tesseract
3.0 produces a lot of undefined references when linking libs. As all the
requirements should be linked with Makefile for shared libraries, following
steps should fix the problem:
1. move ccstruct/callcpp.cpp into cutil/ subdir, which is the correct location
of this source file, stand with its callcpp.h header.
2. modify following variables in Makefile:
libtesseract_main_la_LIBADD = ../wordrec/libtesseract_wordrec.la ../image/libtesseract_image.la ../classify/libtesseract_classify.la ../ccstruct/libtesseract_ccstruct.la ../cutil/libtesseract_cutil.la ../viewer/libtesseract_viewer.la ../dict/libtesseract_dict.la ../ccutil/libtesseract_ccutil.la
libtesseract_ccstruct_la_LIBADD = ../ccutil/libtesseract_ccutil.la ../viewer/libtesseract_viewer.la ../cutil/libtesseract_cutil.la ../image/libtesseract_image.la
libtesseract_classify_la_LIBADD = ../ccutil/libtesseract_ccutil.la ../viewer/libtesseract_viewer.la ../cutil/libtesseract_cutil.la ../ccstruct/libtesseract_ccstruct.la ../dict/libtesseract_dict.la
libtesseract_cutil_la_LIBADD = ../ccutil/libtesseract_ccutil.la ../viewer/libtesseract_viewer.la
libtesseract_dict_la_LIBADD = ../ccutil/libtesseract_ccutil.la ../ccstruct/libtesseract_ccstruct.la ../cutil/libtesseract_cutil.la
libtesseract_image_la_LIBADD = ../cutil/libtesseract_cutil.la ../ccutil/libtesseract_ccutil.la
libtesseract_textord_la_LIBADD =../image/libtesseract_image.la ../classify/libtesseract_classify.la ../ccstruct/libtesseract_ccstruct.la ../cutil/libtesseract_cutil.la ../viewer/libtesseract_viewer.la ../dict/libtesseract_dict.la ../ccutil/libtesseract_ccutil.la
libtesseract_training_la_LIBADD = ../image/libtesseract_image.la ../classify/libtesseract_classify.la ../ccstruct/libtesseract_ccstruct.la ../cutil/libtesseract_cutil.la ../viewer/libtesseract_viewer.la ../dict/libtesseract_dict.la ../ccutil/libtesseract_ccutil.la
libtesseract_wordrec_la_LIBADD = ../ccutil/libtesseract_ccutil.la ../cutil/libtesseract_cutil.la ../classify/libtesseract_classify.la ../dict/libtesseract_dict.la ../image/libtesseract_image.la ../ccstruct/libtesseract_ccstruct.la ../viewer/libtesseract_viewer.la
Even after applying above modification, there are still problems:
1. when linking training:
training/commontraining.cpp:142: undefined reference to `Config'
That is because you set Config as application level variable (for cntraining),
but call it in a shared lib. Maybe you should move corresponding function
ParseArguments into cntraining also.
2. when linking textord:
/tmp/tesseract/BUILD/tesseract-3.00/textord/makerow.cpp:2850: undefined
reference to `tesseract::Tesseract::compare_blobs(PBLOB*, ROW*, PBLOB*, ROW*)'
/tmp/tesseract/BUILD/tesseract-3.00/textord/makerow.cpp:2853: undefined
reference to `tesseract::Tesseract::compare_blobs(PBLOB*, ROW*, PBLOB*, ROW*)'
.libs/tordmain.o: In function `find_components(BLOCK_LIST*, TO_BLOCK_LIST*,
TO_BLOCK_LIST*, TBOX*)':
/tmp/tesseract/BUILD/tesseract-3.00/textord/tordmain.cpp:1013: undefined
reference to `page_image'
/tmp/tesseract/BUILD/tesseract-3.00/textord/tordmain.cpp:142: undefined
reference to `global_monitor'
/tmp/tesseract/BUILD/tesseract-3.00/textord/tordmain.cpp:166: undefined
reference to `global_monitor'
/tmp/tesseract/BUILD/tesseract-3.00/textord/tordmain.cpp:172: undefined
reference to `global_monitor'
/tmp/tesseract/BUILD/tesseract-3.00/textord/tordmain.cpp:179: undefined
reference to `global_monitor'
.libs/tordmain.o: In function `textord_page(ICOORD, BLOCK_LIST*,
TO_BLOCK_LIST*, TO_BLOCK_LIST*, tesseract::Tesseract*)':
/tmp/tesseract/BUILD/tesseract-3.00/textord/tordmain.cpp:554: undefined
reference to `global_monitor'
/tmp/tesseract/BUILD/tesseract-3.00/textord/tordmain.cpp:1013: undefined
reference to `interactive_mode'
.libs/wordseg.o: In function `make_words(ICOORD, float, BLOCK_LIST*,
TO_BLOCK_LIST*, TO_BLOCK_LIST*, tesseract::Tesseract*)':
/tmp/tesseract/BUILD/tesseract-3.00/textord/wordseg.cpp:117: undefined
reference to `global_monitor'
But those references are defined in ccmain. Which means, ccmain and textord are
cross-referencing each other, which is not a good habit for shared libs.
Original issue reported on code.google.com by fundawang@gmail.com on 12 Dec 2010 at 12:10
Original issue reported on code.google.com by
fundawang@gmail.com
on 12 Dec 2010 at 12:10