在 Linux Ubuntu 20.04 上安装/构建最新版本的 Inkscape (v 1.2)

Installing / Building the newest version of Inkscape (v 1.2) on Linux Ubuntu 20.04

我正在尝试在 Linux Ubuntu 20.04 上安装 Inkscape 1.2beta。该网站目前仅提供一个 AppImage 和一个源代码压缩包。由于我想通过命令行访问 Inkscape 的最新功能,因此我需要构建和安装源码压缩包。

INSTALL.md 声明我在安装前需要所有子模块和依赖项。

如何找到这些依赖项以成功构建和安装 Inkscape?

此列表应满足 Linux Ubuntu:

的所有必需依赖项
apt install

cmake

imagemagick
libdouble-conversion-dev
libgdl-3-dev
libagg-dev
libpotrace-dev
libboost-all-dev
libsoup2.4-dev
libgc-dev
libwpg-dev
poppler-utils
libpoppler-dev
libpoppler-glib-dev
libpoppler-private-dev
libvisio-dev libvisio-tools
libcdr-dev
libgtkmm-3.0-dev
libgspell-1-dev
libxslt-dev libxslt1-dev
libreadline6-dev
lib2geom-dev

需要lib2geom-dev来解决.

对于构建 Inkscape:

从 inkscape.org 下载 Inkscape v1.2 的源 tarball 并解压缩

cd <extracted inkscape directory>
mkdir build && cd build
cmake ..
make
make install

如果在 cmake 过程中仍然出现错误..,请在下方评论错误消息中缺少的模块名称。

有关如何构建 Inkscape(和依赖项)的详细信息可以在 repository itself, or Inkscape website 中找到(为了完整起见,步骤从此处的网站复制):

  • 要获取最新的源代码,请使用以下命令(默认下载到当前工作目录的子目录“inkscape”):
git clone --recurse-submodules https://gitlab.com/inkscape/inkscape.git

稍后要更新此代码,请切换到下载文件夹并使用:

git pull --recurse-submodules && git submodule update

默认情况下,git 将下载每个分支和每个提交。如果您使用的机器速度较慢,磁盘空间有限 space,或互联网带宽有限,您可以使用浅克隆和单分支克隆选项来限制它将下载的数据量:

git clone --depth=1 --single-branch --recurse-submodules --shallow-submodule https://gitlab.com/inkscape/inkscape.git

在 Linux

上构建 Inkscape

在上一步中下载源代码的文件夹的根目录下打开一个终端。

安装构建依赖项

下载并运行脚本以安装编译 Inkscape 所需的一切(检查脚本以查看您的发行版是否受支持):

wget -v https://gitlab.com/inkscape/inkscape-ci-docker/-/raw/master/install_dependencies.sh -O install_dependencies.sh
bash install_dependencies.sh --recommended

编译

要使用 CMake 进行编译,请执行以下操作:

mkdir build
cd build
cmake .. -DCMAKE_INSTALL_PREFIX=${PWD}/install_dir -DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache
make -j8
make install

备注:

  • 使用 ccache 是可选的,但可以加快编译速度。
  • make 的可选 -j8 参数告诉它 运行 8 个并行作业。您可以根据计算机上可用的硬件线程(物理内核)数量随意调整它。
  • 推荐的 -DCMAKE_INSTALL_PREFIX 参数允许指定一个自定义的独立安装位置(在上面的示例中 install_dir/ 在构建文件夹内)。它避免安装到系统位置(可能与其他版本的 Inkscape 发生冲突)并允许 运行 同时安装多个版本的 Inkscape。它仍将使用驻留在 ~/.config/inkscape 目录中的所有文件(包括 preferences.xml)。

运行

运行 它来自构建目录:

install_dir/bin/inkscape