我正在尝试使用appimagetool
(https://appimage.org/)创建 OCR 程序的单二进制可执行文件tesseract
(https://github.com/tesseract-ocr)。我在 Ubuntu 19.10 上构建了 tesseract,我希望可执行文件在 Ubuntu 14.01 上运行。
注意:我无法控制旧版本的 Ubuntu,我需要后期版本 tesseract 中的功能。我已经尝试了 tesseract 的现有 AppImage,但它以类似于下面详述的方式失败。
有点遵循本教程:https ://appiomatic.com/blog/creating-appimage-binary-manually-for-linux-from-your-app/我创建了一个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
进一步的研究使我相信我必须手动复制所有依赖项。
所以ldd
在tesseract
可执行文件上使用:
[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 的用例吗?
- 有没有办法调试出了什么问题?
- 是否有自动查找依赖项的工具?
- Ubuntu 14.01 是不是太老了,我应该放弃并重新使用
gocr
.