Linked Questions

Popular Questions

I added -static option to the compilers, also after the LIBLEPTONICA_CFLAGS = in the Makefile. However, the compiled program still cannot run because of a missing shared library.

I was cross-compiling tesseract-4.0.0 from source code. In order to compile to a static build for armv7l, I installed libleptonica-dev, which is the library it needs, then did following configurations.

    ./configure --host=arm-linux-gnueabi

and it generated the Makefile. Then I ran: make LDFLAGS=-static LEPTONICA_CFLAGS=-static No error, the compiler exited with 0. But the program cannot be launched and ldd (on my arm target machine) returns that

    ./tesseract: /usr/lib/libstdc++.so.6: version `GLIBCXX_3.4.21' not found (required by ./tesseract)
    /usr/lib/libenvload.so (0x76ef1000)
    liblept.so.5 => not found                    //Here is the problem
    libpthread.so.0 => /lib/libpthread.so.0 (0x76ec3000)
    libstdc++.so.6 => /usr/lib/libstdc++.so.6 (0x76df0000)
    libm.so.6 => /lib/libm.so.6 (0x76d7c000)
    libgomp.so.1 => /usr/lib/libgomp.so.1 (0x76d61000)
    libgcc_s.so.1 => /lib/libgcc_s.so.1 (0x76d3d000)
    libc.so.6 => /lib/libc.so.6 (0x76c0a000)
    /lib/ld-linux.so.3 (0x76efa000)

It still needs that library.

After that I tried compiling without any '-static' option, only to get the same binary program(tesseract), with the same MD5.

Here is some part of the Makefile generated after ./configure:

    CC = arm-linux-gnueabi-gcc
    CCDEPMODE = depmode=gcc3
    CFLAGS = -g -O2
    CPPFLAGS =  -I/usr/include/leptonica
    CXX = arm-linux-gnueabi-g++
    CXXCPP = arm-linux-gnueabi-g++ -E
    CXXDEPMODE = depmode=gcc3
    CXXFLAGS = -g -O2 -std=c++11
    CYGPATH_W = echo
    DEFS = -DHAVE_CONFIG_H
    DEPDIR = .deps
    DLLTOOL = false
    DSYMUTIL = 
    DUMPBIN = 
    ECHO_C = 
    ECHO_N = -n
    ECHO_T = 
    EGREP = /bin/grep -E
    EXEEXT = 
    FGREP = /bin/grep -F
    FRAMEWORK_OPENCL = 
    GENERIC_API_VERSION = 4.0
    GENERIC_LIBRARY_NAME = tesseract
    GENERIC_LIBRARY_VERSION = 4:0
    GENERIC_MAJOR_VERSION = 4
    GENERIC_MICRO_VERSION = 0
    GENERIC_MINOR_VERSION = 0
    GENERIC_RELEASE = 4.0
    GENERIC_VERSION = 4.0.0
    GREP = /bin/grep
    ICU_I18N_CFLAGS = 
    ICU_I18N_LIBS = 
    ICU_UC_CFLAGS = 
    ICU_UC_LIBS = 
    INSTALL = /usr/bin/install -c
    INSTALL_DATA = ${INSTALL} -m 644
    INSTALL_PROGRAM = ${INSTALL}
    INSTALL_SCRIPT = ${INSTALL}
    INSTALL_STRIP_PROGRAM = $(install_sh) -c -s
    LD = /usr/arm-linux-gnueabi/bin/ld
    LDFLAGS = -static
    LEPTONICA_CFLAGS = -I/usr/include/leptonica
    LEPTONICA_LIBS = -llept
    LIBOBJS = 
    LIBS = -lpthread 
    LIBTOOL = $(SHELL) $(top_builddir)/libtool


    dvidir = ${docdir}
    exec_prefix = ${prefix}
    have_asciidoc = false
    host = arm-unknown-linux-gnueabi
    host_alias = arm-linux-gnueabi
    host_cpu = arm
    host_os = linux-gnueabi
    host_vendor = unknown
    htmldir = ${docdir}
    includedir = ${prefix}/include
    infodir = ${datarootdir}/info
    install_sh = ${SHELL} /home/username/Projects/cpp/tesseract-4.0.0/config/install-sh
    libdir = ${exec_prefix}/lib
    libexecdir = ${exec_prefix}/libexec
    localedir = ${datarootdir}/locale
    localstatedir = ${prefix}/var
    mandir = ${datarootdir}/man
    mkdir_p = $(MKDIR_P)
    oldincludedir = /usr/include
    pango_CFLAGS = 
    pango_LIBS = 
    pdfdir = ${docdir}
    prefix = /usr/local
    program_transform_name = s,x,x,
    psdir = ${docdir}
    runstatedir = ${localstatedir}/run
    sbindir = ${exec_prefix}/sbin

I use '-static' option, and expect the program to be compiled with static libraries, but it turns out to need shared libraries.

Related Questions