Monday, January 18, 2010

compiling tesseract for Linux 32-bit

compiling tesseract for Linux 32-bit under a 64-bit Linux environment wasn't the most straight forward thing... even with -m32 flag set for gcc flags,it failed during linking:

ld -r -o libtesseract_full.o tesseractfull.o \
    libtesseract_main.a \
    ../textord/libtesseract_textord.a \
    ../pageseg/libtesseract_pageseg.a \
    ../wordrec/libtesseract_wordrec.a \
    ../classify/libtesseract_classify.a \
    ../dict/libtesseract_dict.a \
    ../viewer/libtesseract_viewer.a \
    ../image/libtesseract_image.a \
    ../cutil/libtesseract_cutil.a \
    ../ccstruct/libtesseract_ccstruct.a \
    ../ccutil/libtesseract_ccutil.a
ld: Relocatable linking with relocations from format elf32-i386 (tesseractfull.o) to format elf64-x86-64 (libtesseract_full.o) is not supported
make[3]: *** [libtesseract_full.o] Error 1


setting -m32 for LDFLAGS didn't do the trick, ld likes this flag better "-melf_i386", but setting this in LDFLAGS would cause tesseract fail when running configure
I had to manually go under ccmain do the following with -melf_i386:
tesseract-2.03]$ cd ccmain
ccmain]$ ld -r -o libtesseract_full.o tesseractfull.o \
     libtesseract_main.a \
     ../textord/libtesseract_textord.a \
     ../pageseg/libtesseract_pageseg.a \
     ../wordrec/libtesseract_wordrec.a \
     ../classify/libtesseract_classify.a \
     ../dict/libtesseract_dict.a \
     ../viewer/libtesseract_viewer.a \
     ../image/libtesseract_image.a \
     ../cutil/libtesseract_cutil.a \
     ../ccstruct/libtesseract_ccstruct.a \

     ../ccutil/libtesseract_ccutil.a -melf_i386

after that go back one level up and run make ; make install again.
cd ..
make

No comments: