我正在运行 ubuntu mate 18.04,并多次尝试编译 inkscape 源代码。我当时正在遵循这个教程 https://inkscape.org/en/develop/getting-started/
但当我看到描述 cmake 构建标志的那一行时,遇到了问题。我尝试简单地省略标志,并按原样使用它们,但两种方法都失败了。我不确定到底应该在标志中填入什么才能使它们正常工作。
有人可以解释一下命令吗
cmake .. -DCMAKE_INSTALL_PREFIX=$(pwd)/../inst [-DCMAKE_CXX_COMPILER_LAUNCHER=ccache]
我不确定标志是什么,或者应该是什么,但我确信这就是我无法编译的原因。
我尝试编译时省略“XX”,但仍然出现错误
:~/inkscape/build$ cmake .. -DCMAKE_INSTALL_PREFIX=$(pwd)/../inst -DCMAKE_C_COMPILER_LAUNCHER=ccache
------------------------------
Building Makefile for Inkscape
------------------------------
Source Dir: /home/users/inkscape
Binary Dir: /home/users/inkscape/build
-- Creating build files in: /home/s/inkscape/build
-- Could NOT find JeMalloc (missing: JEMALLOC_LIBRARY JEMALLOC_INCLUDE_DIR)
-- Found BoehmGC: /usr/local/lib/libgc.so
-- Found poppler: /usr/lib/x86_64-linux-gnu/libpoppler.so
-- Found poppler-glib: /usr/lib/x86_64-linux-gnu/libpoppler-glib.so
-- Found cairo-svg: /usr/lib/x86_64-linux-gnu/libcairo.so
-- Found poppler-cairo: /usr/lib/x86_64-linux-gnu/libcairo.so
-- Checking for module 'libwpg-0.3'
-- No package 'libwpg-0.3' found
-- Checking for module 'libwpg-0.2'
-- No package 'libwpg-0.2' found
-- Checking for module 'libwpd-0.9'
-- No package 'libwpd-0.9' found
-- Checking for module 'libwpd-stream-0.9'
-- No package 'libwpd-stream-0.9' found
-- Checking for module 'libwpg-0.1'
-- No package 'libwpg-0.1' found
-- Checking for module 'libwpg-stream-0.1'
-- No package 'libwpg-stream-0.1' found
-- Checking for module 'libwpd-0.8'
-- No package 'libwpd-0.8' found
-- Checking for module 'libvisio-0.1'
-- No package 'libvisio-0.1' found
-- Checking for module 'libvisio-0.0'
-- No package 'libvisio-0.0' found
-- Checking for module 'libwpd-0.9'
-- No package 'libwpd-0.9' found
-- Checking for module 'libwpd-stream-0.9'
-- No package 'libwpd-stream-0.9' found
-- Checking for module 'libcdr-0.1'
-- No package 'libcdr-0.1' found
-- Checking for module 'libcdr-0.0'
-- No package 'libcdr-0.0' found
-- Checking for module 'libwpd-0.9'
-- No package 'libwpd-0.9' found
-- Checking for module 'libwpd-stream-0.9'
-- No package 'libwpd-stream-0.9' found
-- Found Popt: /usr/lib/x86_64-linux-gnu/libpopt.so
-- Could not locate the Potrace library headers: the Trace Bitmap and Paintbucket tools will be disabled
-- Using GDL 3.6 or higher
-- Checking for module 'gtkspell3-3.0'
-- No package 'gtkspell3-3.0' found
-- Boost version: 1.65.1
-- Checking for module 'ImageMagick++<=7'
-- No package 'ImageMagick++' found
-- Checking for module 'GraphicsMagick++'
-- No package 'GraphicsMagick++' found
-- Found gettext + msgfmt to convert language files. Translation enabled
-- Found íntltool. inkscape.pot will be re-created if missing.
-- Could not locate the yaml library headers: xverb feature will be disabled
-- Looking for include file ieeefp.h
CMake Error: The following variables are used in this project, but they are set to NOTFOUND.
Please set them or make sure they are set and tested correctly in the CMake files:
POPPLER_INCLUDE_DIR
used as include directory in directory /home/users/inkscape/build/CMakeFiles/CMakeTmp
used as include directory in directory /home/users/inkscape/build/CMakeFiles/CMakeTmp
used as include directory in directory /home/users/inkscape/build/CMakeFiles/CMakeTmp
CMake Error at /usr/share/cmake-3.10/Modules/CheckIncludeFiles.cmake:69 (try_compile):
Failed to configure test project build system.
Call Stack (most recent call first):
CMakeScripts/ConfigChecks.cmake:18 (CHECK_INCLUDE_FILES)
CMakeScripts/DefineDependsandFlags.cmake:392 (include)
CMakeLists.txt:121 (include)
CMake Error: The following variables are used in this project, but they are set to NOTFOUND.
Please set them or make sure they are set and tested correctly in the CMake files:
POPPLER_INCLUDE_DIR
used as include directory in directory /home/users/inkscape
used as include directory in directory /home/uers/inkscape
答案1
您没有安装所有必需的开发库。Inkscape 源使用了一些库,需要安装这些库才能进行编译。
如果你看一下你的输出,你会看到 build 找到了 poppler、cairo-svg,但没有找到 libwpg-0.3、libwpd-stream-0.9 等。
您必须安装所有缺少的库。只需尝试编译并尝试第一个缺少的库。它是 libwpg-0.3。通常包的名称是名称后跟-dev
开发人员库。有时需要版本号,有时不需要。对于 libwpg-0.3,您应该输入:
sudo apt install libwpg-dev
然后你尝试再次编译它,你应该会看到更少的关于缺少库的错误信息。逐个进行,直到安装完所有库。
找到正确的软件包可能很棘手。有时某些库无法按照我在此处描述的方式安装,而只能从源获取。我相信安装库的方式和场景有很多,无法在此全部描述。
最简单的方法是尝试在sudo apt install
命令中输入缺失库的前几个字母,然后按Tab。例如,输入:
sudo apt install libvisio
然后按Tab。自动完成将显示可供安装的软件包。选择带后缀的软件包-dev
。如果这不起作用,请尝试在互联网上查找它或尝试找出库包含在哪个软件包中。
祝你好运,找到所有必需的库。对于 poppler,你可能还必须安装开发库,因为编译器抱怨缺少 POPPLER_INCLUDE_DIR。这表明你安装了 poppler 库,但只有运行时,而不是开发版本。如果你错过了一些名称并安装了错误的库,我不用担心。它只占用一些磁盘空间,不会造成任何损害。
关于编译命令
cmake .. -DCMAKE_INSTALL_PREFIX=$(pwd)/../inst [-DCMAKE_CXX_COMPILER_LAUNCHER=ccache]
-D
开关告诉编译器源代码中使用的其他定义。源代码有一些基于定义的条件编译(https://www.tutorialspoint.com/cprogramming/c_preprocessors.htm)。方括号表示最后一个参数是可选的。因此,使用最后一个参数的正确命令应该是
cmake .. -DCMAKE_INSTALL_PREFIX=$(pwd)/../inst -DCMAKE_CXX_COMPILER_LAUNCHER=ccache
或者直接省略最后一个参数和类型
cmake .. -DCMAKE_INSTALL_PREFIX=$(pwd)/../inst
答案2
首先确保已在软件更新和存储库中选中“源代码”
sudo apt install dpkg-dev
apt source inkscape
sudo apt build-dep inkscape
cd inkscape*/
cmake .
make