Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/linux/24.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何使用AppImageTool创建要在旧Linux上运行的包_Linux_Tesseract_Appimage - Fatal编程技术网

如何使用AppImageTool创建要在旧Linux上运行的包

如何使用AppImageTool创建要在旧Linux上运行的包,linux,tesseract,appimage,Linux,Tesseract,Appimage,我正在尝试使用appimagetool创建OCR程序的单个二进制可执行文件。我已经在Ubuntu19.10上构建了tesseract,我希望可执行文件能够在Ubuntu14.01上运行 注意:我无法控制旧版本的Ubuntu,我需要最新版本tesseract中的功能。我已经尝试过tesseract的现有AppImage,但失败的方式与下面详述的类似 在一定程度上遵循本教程:我创建了一个tesseract.AppDir,具有必要的布局: tesseract.AppDir/AppRun tessera

我正在尝试使用appimagetool创建OCR程序的单个二进制可执行文件。我已经在Ubuntu19.10上构建了tesseract,我希望可执行文件能够在Ubuntu14.01上运行

注意:我无法控制旧版本的Ubuntu,我需要最新版本tesseract中的功能。我已经尝试过tesseract的现有AppImage,但失败的方式与下面详述的类似

在一定程度上遵循本教程:我创建了一个
tesseract.AppDir
,具有必要的布局:

tesseract.AppDir/AppRun
tesseract.AppDir/.DirIcon
tesseract.AppDir/tesseract.desktop
tesseract.AppDir/tesseract.png
tesseract.AppDir/usr
tesseract.AppDir/usr/bin
tesseract.AppDir/usr/bin/tesseract
tesseract.AppDir/usr/lib
tesseract.AppDir/usr/lib/libtesseract.so.5
tesseract.AppDir/usr/lib/libtesseract.so.5.0.0
...
tesseract.AppDir/usr/share
tesseract.AppDir/usr/share/tessdata
tesseract.AppDir/usr/share/tessdata/eng.traineddata
...
tesseract.AppDir/usr/share/tessdata/tessconfigs
...
并创建了AppImage:

[Ubuntu 19.10]$ ~/Downloads/appimagetool-x86_64.AppImage tesseract.AppDir
appimagetool, continuous build (commit effcebc), build 2084 built on 2019-05-01 21:02:41 UTC
Using architecture x86_64
/home/kingsley/Software/Tesseract/tesseract/tesseract.AppDir should be packaged as Tesseract-OCR-x86_64.AppImage
Generating squashfs...
Parallel mksquashfs: Using 6 processors
Creating 4.0 filesystem on Tesseract-OCR-x86_64.AppImage, block size 131072.
[=======================================================================================================================|] 1921/1921 100%

Exportable Squashfs 4.0 filesystem, gzip compressed, data block size 131072
    compressed data, compressed metadata, compressed fragments, compressed xattrs
    duplicates are removed
Filesystem size 73511.40 Kbytes (71.79 Mbytes)
    30.95% of uncompressed filesystem size (237490.75 Kbytes)
Inode table size 5971 bytes (5.83 Kbytes)
    57.29% of uncompressed inode table size (10423 bytes)
Directory table size 1019 bytes (1.00 Kbytes)
    56.90% of uncompressed directory table size (1791 bytes)
Number of duplicate files found 0
Number of inodes 92
Number of files 78
Number of fragments 5
Number of symbolic links  3
Number of device nodes 0
Number of fifo nodes 0
Number of socket nodes 0
Number of directories 11
Number of ids (unique uids + gids) 1
Number of uids 1
    root (0)
Number of gids 1
    root (0)
Embedding ELF...
Marking the AppImage as executable...
Embedding MD5 digest
Success
但是,如果将其复制到较旧的系统,它将不会运行,因为它缺少
libpng16.so.16

[Ubuntu14]$ ./Tesseract-OCR-x86_64.AppImage 
tesseract: error while loading shared libraries: libpng16.so.16: cannot open shared object file: No such file or directory

进一步的研究使我相信我必须手动复制所有依赖项

因此,在
teseract
可执行文件上使用
ldd

[Ubuntu 19.10]$ ldd LOCAL_INSTALL/bin/tesseract 
    linux-vdso.so.1 (0x00007fffd7937000)
    libtesseract.so.5 => not found
    liblept.so.5 => /usr/lib/x86_64-linux-gnu/liblept.so.5 (0x00007f44c03d3000)
    libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007f44c03b0000)
    libstdc++.so.6 => /usr/lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007f44c01c2000)
    libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007f44c01a8000)
    libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f44bffb7000)
    libpng16.so.16 => /usr/lib/x86_64-linux-gnu/libpng16.so.16 (0x00007f44bff7d000)
    libjpeg.so.8 => /usr/lib/x86_64-linux-gnu/libjpeg.so.8 (0x00007f44bfef8000)
    libgif.so.7 => /usr/lib/x86_64-linux-gnu/libgif.so.7 (0x00007f44bfeed000)
    libtiff.so.5 => /usr/lib/x86_64-linux-gnu/libtiff.so.5 (0x00007f44bfe6c000)
    libwebp.so.6 => /usr/lib/x86_64-linux-gnu/libwebp.so.6 (0x00007f44bfc03000)
    libopenjp2.so.7 => /usr/lib/x86_64-linux-gnu/libopenjp2.so.7 (0x00007f44bfbad000)
    libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f44bfa5c000)
    libz.so.1 => /lib/x86_64-linux-gnu/libz.so.1 (0x00007f44bfa40000)
    /lib64/ld-linux-x86-64.so.2 (0x00007f44c0706000)
    libzstd.so.1 => /usr/lib/x86_64-linux-gnu/libzstd.so.1 (0x00007f44bf999000)
    liblzma.so.5 => /lib/x86_64-linux-gnu/liblzma.so.5 (0x00007f44bf972000)
    libjbig.so.0 => /usr/lib/x86_64-linux-gnu/libjbig.so.0 (0x00007f44bf764000)
然后,我将所有这些共享库复制到
tesseract.AppDir/usr/lib/
中,并再次重建AppImage

在Ubuntu 14上的测试仍然失败:

[Ubuntu14]$ ./Tesseract-OCR-x86_64.AppImage 
Segmentation fault (core dumped)
Segmentation fault (core dumped)
Segmentation fault (core dumped)
Segmentation fault (core dumped)
编辑:我尝试制作AppImage,一个接一个地添加中间的.so文件。只有当我最终在
libc.so.6中复制时,我才得到seg。过错但是,如果不使用此库,可执行文件运行将失败,原因是:

tesseract: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.22' not found (required by /tmp/.mount_Tesser6wDkZB/lib/liblept.so.5)
似乎问题出在
liblept.so.5

现在我几乎没有主意了

  • 这不是AppImages的用例吗
  • 有没有办法调试出了什么问题
  • 是否有自动查找依赖项的工具
  • Ubuntu14.01是不是太老了,我应该放弃并重新使用
    gocr
  • 这不是AppImages的用例吗

    这肯定是一个有效的用例

    有没有办法调试出了什么问题

    是的,您可以使用
    strace
    LD_DEBUG=libs
    环境变量查看正在加载的内容。有关调试AppImage的详细信息,请检查:

    是否有自动查找依赖项的工具

    是的,请查收

    你应该使用哪一个取决于你的应用程序是否可以建立在最古老的稳定系统上。如果答案是“是”,则可以使用
    linuxdeploy
    ,否则可以使用
    appmage builder
    。我建议阅读,以辨别使用哪种工具

    Ubuntu14.01是不是太老了,我应该放弃,重新使用gocr


    可以证明,您可以使用在ubuntu 20.04中构建AppImage。

    如果有人在这里寻找如何实际解决这个问题,我就是这样解决的

    通过一个接一个地添加库,我能够确定问题的核心是
    liblept.so.5
    是用GLIBC 22.2编译的,而Ubuntu 14目标没有这个。我发现这是唯一一个有这个问题的图书馆

    然而,仅仅包括
    libc.so.6也会导致所有这些分段错误。我不知道这是为什么,我仍然想知道为什么。所以我四处寻找替代品

    我尝试的一种方法是编译tesseract以链接到静态liblept,但这并没有立即起作用,我也没有时间对其进行全面研究。也许这是一个好办法。最后我考虑编译一个本地的leptonica库,这样就有了一个本地的Ubuntu 14版本的.so,而应用程序映像就可以使用它


    显然,这不是最好的解决方案,因为它没有包含在软件包中,但这足以让它为我工作。

    非常感谢您的时间。这个答案为我自己解决这个问题指明了正确的方向。如果没有配套的ld linux,你就不能使用libc.so.6二进制文件,还有其他一些库是密切相关的,也必须捆绑使用。这些文件的详细列表可以在以下位置找到:如果您捆绑libc.so.6,但您仍然从系统中加载一些库(这是一种完全有效的方法),那么您必须在运行时检测并选择嵌入的库和系统中的库之间的较新库版本。这是一篇关于这个主题的帖子,作为最后的评论,我们已经在appimage builder上解决了此类问题,它对用户来说是完全透明的。因此,如果您想要/需要嵌入libc.So.6,那么您应该使用appimage builder。