如何从源代码构建 libpoppler?

发布于 2024-12-27 12:27:36 字数 96 浏览 2 评论 0原文

我刚刚将 poppler 下载到 Linux 系统,我想将它合并到我的应用程序中来解析 pdf 文件。
(我的目标是将 pdf 文件转换为纯文本。)
我该怎么做?

I just download poppler to Linux system,and I want to incorporate it in my app to parse pdf file.
(My goal is to convert pdf file to plain text.)
How can I do this?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

口干舌燥 2025-01-03 12:27:37

Poppler 的 git 树包含一个无用的 INSTALL 文档,它只是告诉你运行 ./configure,但它们不包含 automake/autoconf 自动生成的文件(包括配置) git。 (可能他们确实将它们包含在 tarball 源版本中。)

我刚刚从 git 源(在 Ubuntu 15.04 上)构建了 poppler,如下所示:

git clone --depth 50 --no-single-branch git://git.freedesktop.org/git/poppler/poppler
cmake -G 'Unix Makefiles'  # other -G options are to generate project files for various IDEs
# look at the output.  If it didn't find some libraries,
# install them with your package manager and re-run cmake
make -j4
# optionally:
sudo make install

看来他们维护了 autoconf/automake 构建设置,因此您可以使用该 OR cmake 创建一个 <代码>Makefile。

如果您只是想看看最新的 git poppler 是否比发行版包更好用,则不需要 sudo make install,只需运行 utils/pdftotext 或源目录中的任何内容。它显然告诉链接器将构建路径作为库搜索路径嵌入到二进制文件中,因此运行 /usr/local/src/poppler/utils/pdftotext 可以工作,并找到 /usr /local/src/poppler/libpoppler.so.52

如果最新的 poppler 确实比发行版打包的 poppler 工作得更好,您应该使用 sudo make install 将其安装到 /usr/local/bin 。当您升级到发行版的下一个版本时,请检查您的 /usr/local.conf 文件。通常,新的发行版版本会比您从源代码构建时更新,因此您应该从 /usr/local/{bin,share,lib,man,include} 中删除您的版本。 (或者如果支持的话,在源目录中make uninstall)。

Poppler's git tree includes a useless INSTALL doc that just tells you to run ./configure, but they don't include automake/autoconf auto-generated files (including configure) in git. (Probably they do include them in tarball source releases.)

I just built poppler from git source (on Ubuntu 15.04) like so:

git clone --depth 50 --no-single-branch git://git.freedesktop.org/git/poppler/poppler
cmake -G 'Unix Makefiles'  # other -G options are to generate project files for various IDEs
# look at the output.  If it didn't find some libraries,
# install them with your package manager and re-run cmake
make -j4
# optionally:
sudo make install

It appears that they maintain an autoconf/automake build setup, so you can use that OR cmake to create a Makefile.

If you just want to see if the latest git poppler works better than the distro package, you don't need to sudo make install, you can just run utils/pdftotext or whatever right from the source directory. It apparently tells the linker to embed the build path into the binary, as a library search path, so running /usr/local/src/poppler/utils/pdftotext works, and finds /usr/local/src/poppler/libpoppler.so.52.

If the latest poppler does work better than the distro-packaged poppler, you should install it to /usr/local/bin with sudo make install. When you upgrade to the next version of your distro, check your /usr/local. Often the new distro version will be newer than when you built it from source, so you should just remove your version from /usr/local/{bin,share,lib,man,include}. (Or make uninstall in the source dir, if supported).

旧人 2025-01-03 12:27:37

他们的网站解释得非常清楚:

Poppler 可从 git 获取。要克隆存储库,请使用以下命令:

git clone git://git.freedesktop.org/git/poppler/poppler

下载源代码后,请阅读 INSTALL 文件,其中显示:

  1. cd 到包含包源代码和类型的目录
    ./configure 为您的系统配置软件包。

  2. 输入“make”来编译包。

  3. 键入“make install”来安装程序和任何数据文件,然后
    文档。

Their website explains it very clearly :

Poppler is available from git. To clone the repository use the following command:

git clone git://git.freedesktop.org/git/poppler/poppler

Once you download the source code, read the INSTALL file where it says :

  1. cd to the directory containing the package's source code and type
    ./configure to configure the package for your system.

  2. Type `make' to compile the package.

  3. Type `make install' to install the programs and any data files and
    documentation.

一抹微笑 2025-01-03 12:27:37

由于时间过去了,似乎有些不确定,我也看了看。

2021 年底,他们的主页表示

我们通过 gitlab CI 运行持续集成

我查看了 他们的 .gitlab-ci.yml 有许多构建任务。现在我们似乎像这样构建 libpoppler:

git clone git://git.freedesktop.org/git/poppler/test test.repo
mkdir -p build && cd build
cmake -DTESTDATADIR=`pwd`/../test.repo -G Ninja ..
ninja

Since some time has passed and it seems there was some uncertainty, I also took a look.

At the end of 2021, their homepage says

We run continuous integration via the gitlab CI

I checked out their .gitlab-ci.yml which has many build tasks. It would seem these days we build libpoppler like this:

git clone git://git.freedesktop.org/git/poppler/test test.repo
mkdir -p build && cd build
cmake -DTESTDATADIR=`pwd`/../test.repo -G Ninja ..
ninja
调妓 2025-01-03 12:27:37

如果您想从源代码安装poppler而不影响系统(提供发行版)中的poppler,我建议JHBuild,就像这样简单:

jhbuild buildone poppler-data poppler-test-files poppler

If you want to install poppler from source without affecting the poppler from your system (distro provided) I recommend JHBuild, as easy as:

jhbuild buildone poppler-data poppler-test-files poppler
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文