我正在 QtCreator 中开发基于 Cmake 的 C++ 项目。我正在尝试在我的项目中使用 mlpack,但是一旦我将该行包含#include <mlpack/core.hpp>到我唯一的源文件中,我就会收到与 mlpack/core.hpp 包含的一些 libxml 文件有关的错误:
In file included from /usr/local/include/mlpack/core/util/save_restore_utility.hpp:26:0,
from /usr/local/include/mlpack/core.hpp:171,
from /home/revinci/code/workspaces/qt_ws/Semantic_Perception/src/features_slic.cpp:18:
/usr/include/libxml2/libxml/parser.h:15:31: fatal error: libxml/xmlversion.h: No such file or directory
#include <libxml/xmlversion.h>
现在,我进去/usr/include/libxml2/libxml/发现里面parser.h有线#include <libxml/xmlversion.h>。所以,我看到了,xmlversion.h并且parser.h在同一个文件夹中并尝试了破解:我将#include <libxml/xmlversion.h>in更改parser.h为#include "xmlversion.h"仅得到以下错误:
In file included from /usr/include/libxml2/libxml/parser.h:15:0,
from /usr/local/include/mlpack/core/util/save_restore_utility.hpp:26,
from /usr/local/include/mlpack/core.hpp:171,
from /home/revinci/code/workspaces/qt_ws/Semantic_Perception/src/features_slic.cpp:18:
/usr/include/libxml2/libxml/xmlversion.h:13:31: fatal error: libxml/xmlexports.h: No such file or directory
#include <libxml/xmlexports.h>
这基本上告诉我它找不到xmlexports.h(包含在 中xmlversion.h)。更重要的是,与和xmlexports.h位于同一目录中!xmlversion.hparser.h
我尝试了此处libxml2-dev提到的解决方案并(再次)安装了 and libxslt1-dev,但我的问题没有解决。
我认为这可能与正确指定我的包含路径有关。我试图添加/usr/include/libxml2到 QtCreator 的构建环境中存在的各种路径环境变量(PATH和INCLUDE_PATH)CPATH,但无济于事。我的CMakeLists.txt样子是这样的:
project(Semantic_Perception)
cmake_minimum_required(VERSION 2.8)
#Vigra Headers
include_directories(
include
)
file(GLOB_RECURSE VigraImpex include/impex/)
add_library(VigraImpex ${VigraImpex})
#LibXml2 Headers
find_package(LibXml2 REQUIRED)
#Armadillo Headedrs
find_package(Armadillo REQUIRED)
include_directories(${ARMADILLO_INCLUDE_DIRS})
#Boost Headers
find_package(Boost 1.54.0 REQUIRED)
add_executable(features_slic src/features_slic.cpp)
target_link_libraries(features_slic
VigraImpex
${ARMADILLO_LIBRARIES}
)
顺便说一句:LibXml2、Armadillo 和 Boost 都是我尝试使用的库的依赖项 - mlpack。该命令find_pakcage(mlpack)不起作用,因为Findmlpack.cmake我的系统上任何地方都没有文件,而且我在互联网上也找不到。