0

I'm working on a Cmake based C++ project in QtCreator. I am trying to use mlpack in my project, but as soon as I include the line #include <mlpack/core.hpp> to my only source file, I get an error pertaining to some libxml files that are included by mlpack/core.hpp:

    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>

Now, I went into /usr/include/libxml2/libxml/ and found parser.h with the line #include <libxml/xmlversion.h> in it. So, I saw that xmlversion.h and parser.h are in the same folder and tried a hack: I changed the #include <libxml/xmlversion.h> in parser.h to #include "xmlversion.h" only to get the following error:

    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>

Which is basically telling me that it can't find xmlexports.h (included by xmlversion.h). More importantly, xmlexports.h is in the same directory as xmlversion.h and parser.h!

I tried the solution mentioned here and installed libxml2-dev (again) and libxslt1-dev, but my problem wasn't solved.

I think this may have something to do with specifying my include paths correctly. I've tried to add /usr/include/libxml2 to the various path environment variables (PATH, INCLUDE_PATH and CPATH) that are present in my build environment in QtCreator, but to no avail. My CMakeLists.txt looks like this:

    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}
    )

BTW: LibXml2, Armadillo and Boost are all dependencies of the library I am trying to use - mlpack. The command find_pakcage(mlpack) won't work because there is no Findmlpack.cmake file on my system anywhere, and I couldn't find one on the internet either.

Community
  • 1
  • 1
shinvu
  • 601
  • 2
  • 7
  • 23
  • You should probably add `include_directories(${LIBXML2_INCLUDE_DIR})` after the line `find_package(LibXml2 REQUIRED)` – nwellnhof Dec 13 '15 at 14:17
  • Well, as of now I've simply gone with the (painful) hack of changing all `#include ` to `#include "*.h"` so that I could move forward with my project. I'll try out what you suggested as soon as I'm finished (probably two more days). – shinvu Dec 13 '15 at 17:33
  • Ah yes, that worked perfectly! I have a follow-up question, though. How do you know what the name of the variable to use in `include_directories` will be? I had tried adding the line `include_directories(${LIBXML2_INCLUDE_DIRS})` (based on the fact that a similar addition had worked for Armadillo) before and it didn't work. – shinvu Dec 17 '15 at 04:39

0 Answers0