CentOS 7 : how to build Leptonica Library


Leptonica Library

Homepage: https://github.com/DanBloomberg/leptonica

Dependencies:
ZLIB LIBPNG JPEG LIBTIFF LIBWEBP

yum install -y zlib-devel libpng-devel openjpeg-devel libtiff-devel libwebp-devel

Step 1: clone repo leptonica

[root@tutorialspots ~]# git clone https://github.com/DanBloomberg/leptonica
Cloning into 'leptonica'...
remote: Enumerating objects: 521, done.
remote: Counting objects: 100% (521/521), done.
remote: Compressing objects: 100% (445/445), done.
remote: Total 12972 (delta 264), reused 162 (delta 76), pack-reused 12451
Receiving objects: 100% (12972/12972), 22.70 MiB | 13.73 MiB/s, done.
Resolving deltas: 100% (10411/10411), done.

Step 2:

cd leptonica
export CC=${CC:-gcc} 
sh ./autogen.sh

Result

[root@tutorialspots leptonica]# sh ./autogen.sh
libtoolize: putting auxiliary files in AC_CONFIG_AUX_DIR, `config'.
libtoolize: copying file `config/ltmain.sh'
libtoolize: putting macros in AC_CONFIG_MACRO_DIR, `m4'.
libtoolize: copying file `m4/libtool.m4'
libtoolize: copying file `m4/ltoptions.m4'
libtoolize: copying file `m4/ltsugar.m4'
libtoolize: copying file `m4/ltversion.m4'
libtoolize: copying file `m4/lt~obsolete.m4'
configure.ac:8: installing 'config/config.guess'
configure.ac:8: installing 'config/config.sub'
configure.ac:10: installing 'config/install-sh'
configure.ac:10: installing 'config/missing'
prog/Makefile.am: installing 'config/depcomp'
parallel-tests: installing 'config/test-driver'

Step 3:

CFLAGS="-std=gnu99"
./configure CFLAGS="${CFLAGS}"

Result:

[root@tutorialspots leptonica]# ./configure CFLAGS="${CFLAGS}"
checking build system type... x86_64-unknown-linux-gnu
checking host system type... x86_64-unknown-linux-gnu
checking how to print strings... printf
checking for gcc... gcc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables...
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ISO C89... none needed
checking for a sed that does not truncate output... /usr/bin/sed
checking for grep that handles long lines and -e... /usr/bin/grep
checking for egrep... /usr/bin/grep -E
checking for fgrep... /usr/bin/grep -F
checking for ld used by gcc... /usr/bin/ld
checking if the linker (/usr/bin/ld) is GNU ld... yes
checking for BSD- or MS-compatible name lister (nm)... /usr/bin/nm -B
checking the name lister (/usr/bin/nm -B) interface... BSD nm
checking whether ln -s works... yes
checking the maximum length of command line arguments... 1572864
checking whether the shell understands some XSI constructs... yes
checking whether the shell understands "+="... yes
checking how to convert x86_64-unknown-linux-gnu file names to x86_64-unknown-linux-gnu format... func_convert_file_noop
checking how to convert x86_64-unknown-linux-gnu file names to toolchain format... func_convert_file_noop
checking for /usr/bin/ld option to reload object files... -r
checking for objdump... objdump
checking how to recognize dependent libraries... pass_all
checking for dlltool... no
checking how to associate runtime and link libraries... printf %s\n
checking for ar... ar
checking for archiver @FILE support... @
checking for strip... strip
checking for ranlib... ranlib
checking for gawk... gawk
checking command to parse /usr/bin/nm -B output from gcc object... ok
checking for sysroot... no
checking for mt... no
checking if : is a manifest tool... no
checking how to run the C preprocessor... gcc -E
checking for ANSI C header files... yes
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
checking for dlfcn.h... yes
checking for objdir... .libs
checking if gcc supports -fno-rtti -fno-exceptions... no
checking for gcc option to produce PIC... -fPIC -DPIC
checking if gcc PIC flag -fPIC -DPIC works... yes
checking if gcc static flag -static works... no
checking if gcc supports -c -o file.o... yes
checking if gcc supports -c -o file.o... (cached) yes
checking whether the gcc linker (/usr/bin/ld -m elf_x86_64) supports shared libraries... yes
checking whether -lc should be explicitly linked in... no
checking dynamic linker characteristics... GNU/Linux ld.so
checking how to hardcode library paths into programs... immediate
checking whether stripping libraries is possible... yes
checking if libtool supports shared libraries... yes
checking whether to build shared libraries... yes
checking whether to build static libraries... yes
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for a thread-safe mkdir -p... /usr/bin/mkdir -p
checking whether make sets $(MAKE)... yes
checking for style of include used by make... GNU
checking whether make supports nested variables... yes
checking dependency style of gcc... gcc3
checking for gawk... (cached) gawk
checking for gcc... (cached) gcc
checking whether we are using the GNU C compiler... (cached) yes
checking whether gcc accepts -g... (cached) yes
checking for gcc option to accept ISO C89... (cached) none needed
checking how to run the C preprocessor... gcc -E
checking whether ln -s works... yes
checking whether make sets $(MAKE)... (cached) yes
checking for cos in -lm... yes
checking for pkg-config... /usr/bin/pkg-config
checking pkg-config is at least version 0.9.0... yes
checking for ZLIB... yes
checking for LIBPNG... yes
checking for JPEG... yes
checking for DGifOpenFileHandle in -lgif... yes
checking gif_lib.h usability... yes
checking gif_lib.h presence... yes
checking for gif_lib.h... yes
checking giflib is at least version 5.1 (but not 5.1.2)... no
checking for LIBTIFF... yes
checking for LIBWEBP... yes
checking for LIBWEBPMUX... no
checking for WebPAnimEncoderOptionsInit in -lwebpmux... no
checking for LIBJP2K... yes
checking whether to enable debugging...
checking whether make supports nested variables... (cached) yes
checking for size_t... yes
checking whether byte ordering is bigendian... no
checking whether compiler supports -Wl,--as-needed... yes
checking for fmemopen... yes
checking for fstatat... yes
checking Major version... 1
checking Minor version... 80
checking Point version... 0
checking whether ln -s works... yes
checking that generated files are newer than configure... done
configure: creating ./config.status
config.status: creating Makefile
config.status: creating src/endianness.h
config.status: creating src/Makefile
config.status: creating prog/Makefile
config.status: creating lept.pc
config.status: creating cmake/templates/LeptonicaConfig.cmake
config.status: creating cmake/templates/LeptonicaConfig-version.cmake
config.status: creating config_auto.h
config.status: executing libtool commands
config.status: executing depfiles commands

Step 4: make

Result:

...
  CCLD     sorttest
  CC       splitimage2pdf.o
  CCLD     splitimage2pdf
  CC       sudokutest.o
  CCLD     sudokutest
  CC       textorient.o
  CCLD     textorient
  CC       trctest.o
  CCLD     trctest
  CC       underlinetest.o
  CCLD     underlinetest
  CC       warpertest.o
  CCLD     warpertest
  CC       wordsinorder.o
  CCLD     wordsinorder
  CC       writemtiff.o
  CCLD     writemtiff
  CC       yuvtest.o
  CCLD     yuvtest
make[2]: Leaving directory `/root/leptonica/prog'
make[2]: Entering directory `/root/leptonica'
make[2]: Leaving directory `/root/leptonica'
make[1]: Leaving directory `/root/leptonica'

Step 5: make install

Result:

[root@tutorialspots leptonica]# make install
Making install in src
make[1]: Entering directory `/root/leptonica/src'
make[2]: Entering directory `/root/leptonica/src'
 /usr/bin/mkdir -p '/usr/local/lib'
 /bin/sh ../libtool   --mode=install /usr/bin/install -c   liblept.la '/usr/local/lib'
libtool: install: /usr/bin/install -c .libs/liblept.so.5.0.4 /usr/local/lib/liblept.so.5.0.4
libtool: install: (cd /usr/local/lib && { ln -s -f liblept.so.5.0.4 liblept.so.5 || { rm -f liblept.so.5 && ln -s liblept.so.5.0.4 liblept.so.5; }; })
libtool: install: (cd /usr/local/lib && { ln -s -f liblept.so.5.0.4 liblept.so || { rm -f liblept.so && ln -s liblept.so.5.0.4 liblept.so; }; })
libtool: install: /usr/bin/install -c .libs/liblept.lai /usr/local/lib/liblept.la
libtool: install: /usr/bin/install -c .libs/liblept.a /usr/local/lib/liblept.a
libtool: install: chmod 644 /usr/local/lib/liblept.a
libtool: install: ranlib /usr/local/lib/liblept.a
libtool: finish: PATH="/root/.nvm/versions/node/v14.8.0/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.191.b12-1.el7_6.x86_64/jre/bin:/usr/local/go/bin:/root/bin:/sbin" ldconfig -n /usr/local/lib
----------------------------------------------------------------------
Libraries have been installed in:
   /usr/local/lib

If you ever happen to want to link against installed libraries
in a given directory, LIBDIR, you must either use libtool, and
specify the full pathname of the library, or use the `-LLIBDIR'
flag during linking and do at least one of the following:
   - add LIBDIR to the `LD_LIBRARY_PATH' environment variable
     during execution
   - add LIBDIR to the `LD_RUN_PATH' environment variable
     during linking
   - use the `-Wl,-rpath -Wl,LIBDIR' linker flag
   - have your system administrator add LIBDIR to `/etc/ld.so.conf'

See any operating system documentation about shared libraries for
more information, such as the ld(1) and ld.so(8) manual pages.
----------------------------------------------------------------------
 /usr/bin/mkdir -p '/usr/local/include/leptonica'
 /usr/bin/install -c -m 644 allheaders.h alltypes.h array.h arrayaccess.h bbuffer.h bilateral.h bmf.h bmfdata.h bmp.h ccbord.h colorfill.h dewarp.h endianness.h environ.h gplot.h heap.h imageio.h jbclass.h leptwin.h list.h morph.h pix.h ptra.h queue.h rbtree.h readbarcode.h recog.h regutils.h stack.h stringcode.h sudoku.h watershed.h '/usr/local/include/leptonica'
make  install-data-hook
make[3]: Entering directory `/root/leptonica/src'
cd /usr/local/lib;\
for ext in a la so sl dylib; do\
        if test -f liblept.$ext; then\
                ln -s liblept.$ext libleptonica.$ext;\
        fi;\
done
make[3]: Leaving directory `/root/leptonica/src'
make[2]: Leaving directory `/root/leptonica/src'
make[1]: Leaving directory `/root/leptonica/src'
Making install in prog
make[1]: Entering directory `/root/leptonica/prog'
make[2]: Entering directory `/root/leptonica/prog'
 /usr/bin/mkdir -p '/usr/local/bin'
  /bin/sh ../libtool   --mode=install /usr/bin/install -c convertfilestopdf convertfilestops convertformat convertsegfilestopdf convertsegfilestops converttopdf converttops fileinfo imagetops xtractprotos '/usr/local/bin'
libtool: install: /usr/bin/install -c .libs/convertfilestopdf /usr/local/bin/convertfilestopdf
libtool: install: /usr/bin/install -c .libs/convertfilestops /usr/local/bin/convertfilestops
libtool: install: /usr/bin/install -c .libs/convertformat /usr/local/bin/convertformat
libtool: install: /usr/bin/install -c .libs/convertsegfilestopdf /usr/local/bin/convertsegfilestopdf
libtool: install: /usr/bin/install -c .libs/convertsegfilestops /usr/local/bin/convertsegfilestops
libtool: install: /usr/bin/install -c .libs/converttopdf /usr/local/bin/converttopdf
libtool: install: /usr/bin/install -c .libs/converttops /usr/local/bin/converttops
libtool: install: /usr/bin/install -c .libs/fileinfo /usr/local/bin/fileinfo
libtool: install: /usr/bin/install -c .libs/imagetops /usr/local/bin/imagetops
libtool: install: /usr/bin/install -c .libs/xtractprotos /usr/local/bin/xtractprotos
make[2]: Nothing to be done for `install-data-am'.
make[2]: Leaving directory `/root/leptonica/prog'
make[1]: Leaving directory `/root/leptonica/prog'
make[1]: Entering directory `/root/leptonica'
make[2]: Entering directory `/root/leptonica'
make[2]: Nothing to be done for `install-exec-am'.
 /usr/bin/mkdir -p '/usr/local/lib/cmake/'
 /usr/bin/install -c -m 644 cmake/templates/LeptonicaConfig.cmake cmake/templates/LeptonicaConfig-version.cmake '/usr/local/lib/cmake/'
 /usr/bin/mkdir -p '/usr/local/lib/pkgconfig'
 /usr/bin/install -c -m 644 lept.pc '/usr/local/lib/pkgconfig'
make[2]: Leaving directory `/root/leptonica'
make[1]: Leaving directory `/root/leptonica'

1 Comment

Leave a Reply