仅“ -static”选项足以进行静态构建吗? (-static不起作用)

时间:2019-02-03 05:37:29

标签: c makefile compilation static tesseract

我在-static中的LIBLEPTONICA_CFLAGS =之后也向编译器添加了Makefile选项。但是,由于缺少共享库,编译后的程序仍然无法运行。

我正在从源代码交叉编译tesseract-4.0.0。为了编译为armv7l的静态版本,我安装了libleptonica-dev,这是它需要的库,然后进行了以下配置。

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

,它生成了Makefile。然后我跑了:         使LDFLAGS =-静态LEPTONICA_CFLAGS =-静态 没有错误,编译器以0退出。 但是该程序无法启动,并且ldd(在我的手臂目标计算机上)返回了

    ./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)

它仍然需要该库。

此后,我尝试不使用任何“ -static”选项进行编译,只是获得具有相同MD5的相同二进制程序(tesseract)。

这是Makefile之后生成的./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

我使用'-static'选项,并期望该程序使用静态库进行编译,但事实证明它需要共享库。

0 个答案:

没有答案