Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt Creator and other tools
  4. [SOLVED]libxml/xmlexports.h : No such file or directory

[SOLVED]libxml/xmlexports.h : No such file or directory

Scheduled Pinned Locked Moved Qt Creator and other tools
6 Posts 2 Posters 6.3k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • H Offline
    H Offline
    heatblazer
    wrote on last edited by
    #1

    Hello, recently I am following the example for libxml from their official site. The strange error that qtcreator reports is :
    @#ifndef XML_VERSION_H
    #define XML_VERSION_H

    #include <libxml/xmlexports.h>

    #ifdef __cplusplus
    extern "C" {
    #endif

    /*

    • use those to be sure nothing nasty will happen if
    • your library and includes mismatch
      /
      #ifndef LIBXML2_COMPILING_MSCCDEF
      XMLPUBFUN void XMLCALL xmlCheckVersion(int version); // ERROR HERE
      #endif /
      LIBXML2_COMPILING_MSCCDEF */
      @
      But I am sure the header is present in usr/include, Ive less-ed it and double checked for it, also intellisense or autocomplete (not sure how you call it) show all libxml funcions. Ive read this topic :
      https://stackoverflow.com/questions/5636144/error-libxml-parser-h-no-such-file-or-directory/5981599#5981599 but here this does not fix the issue. Here are my includes, or more like the whole example I am following:
      @#include <libxml2/libxml/tree.h>
      #include <libxml2/libxml/parser.h>
      #include <libxml2/libxml/xmlversion.h>
      #include <libxml2/libxml/xmlexports.h>

    #include <stdio.h>

    static const char* document = "<quiz />";

    static void exampleXMLParse(const char*, int);

    int main(void) {
    LIBXML_TEST_VERSION
    exampleXMLParse(document, 6);
    xmlCleanupParser();
    return(0);
    }

    static void exampleXMLParse(const char *content, int length) {
    xmlDocPtr doc;
    doc = xmlReadMemory(content, length, "TestXML.xml", NULL, 0);
    if ( ! doc ) {
    fprintf(stderr, "ERROR READING %s \n", "TestXML");
    return;
    }
    xmlFreeDoc(doc);
    }
    @
    Any info ?

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      Did you add:

      @INCLUDE += /usr/include/libxml2@

      to your pro file ?

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • H Offline
        H Offline
        heatblazer
        wrote on last edited by
        #3

        Hello, thanks, just did but I got the following errno:
        (assuming the above code)
        @
        undefined reference to 'xmlCheckVersion'
        undefined reference to 'xmlReadMemory'
        undefined reference to 'xmlFreeDoc'
        undefined reference to 'xmlCleanupParser'
        @

        Here is my pro. file:
        @
        #-------------------------------------------------

        Project created by QtCreator 2014-07-05T12:46:42

        #-------------------------------------------------

        QT += core gui

        greaterThan(QT_MAJOR_VERSION, 4): QT += widgets

        TARGET = DirectoryDeleter
        TEMPLATE = app
        INCLUDEPATH += /usr/include/libxml2

        SOURCES += main.cpp
        DirectoryDeleter.cpp
        Worker.cpp
        Daemon.cpp
        xmltest.cpp #added for testing

        HEADERS +=
        DirectoryDeleter.h
        Worker.h
        Daemon.h

        @

        Ive cleaned the project, ran qMake form qtcreator, build it again then tried to run... this is the issue. [EDIT] Ive searched for INCLUDE tag but the qtcreator offered INCLUDEPATH and include() ... I guess INCLUDEPATH replaces INCLUDE so I think I`ve did it rigth.

        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          You are not linking to libxml2

          You need to add

          @LIBS += -lxml2@

          To your pro file

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          0
          • H Offline
            H Offline
            heatblazer
            wrote on last edited by
            #5

            Thank you so much. I had no idea this is manually done. In gcc I was adding the -lxml2 and it was OK, but no idea the pro. needed it. Thank you again - you were a lifesaver :)

            1 Reply Last reply
            0
            • SGaistS Offline
              SGaistS Offline
              SGaist
              Lifetime Qt Champion
              wrote on last edited by
              #6

              Qt can't guess your external dependencies ;)

              You're welcome !

              Since it's all working now, please update the thread title prepending [solved] so other forum users may know a solution has been found :)

              Interested in AI ? www.idiap.ch
              Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

              1 Reply Last reply
              0

              • Login

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • Users
              • Groups
              • Search
              • Get Qt Extensions
              • Unsolved