Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Crash when calling function from external library (libxml2)
Forum Updated to NodeBB v4.3 + New Features

Crash when calling function from external library (libxml2)

Scheduled Pinned Locked Moved Solved General and Desktop
5 Posts 2 Posters 483 Views 2 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
    Hound
    wrote on last edited by
    #1

    Hello!
    I downloaded libxml2 binaries (version libxml2-2.9.1-win32-x86_64), and imported it to my project:

    INCLUDEPATH += $$_PRO_FILE_PWD_/Libraries/libxml2/include/libxml2
    LIBS += -L$$_PRO_FILE_PWD_/Libraries/libxml2/lib -lxml2
    

    However, calling a function (htmlParseFile) first threw a bunch of undefined reference errors, and now the program crashes instantly without any trace of errors in the debugger.

    htmlDocPtr ptr;
    ptr = htmlParseFile("networkreply.txt", "UTF-8");
    

    Any idea what might be causing this, and would it be possible to find the error logs somewhere ?

    Thanks!

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

      Hi
      Those binaries, what compiler are those for?
      and what compiler are you using ?

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

        This was stated: "The libraries in these packages are made using GCC (MinGW) toolchain. It is presently not possible to use these libraries with any recent version of the Microsoft Visual C compiler because of conflicting C-runtimes. To help you resist the temptation, the import libraries (.LIB) are not provided at all. If you need these libraries in an environment which mandates the use of the Microsoft toolchain, you will have to build them from source yourself."

        I'm using MinGW 64-bit.

        mrjjM 1 Reply Last reply
        0
        • H Hound

          This was stated: "The libraries in these packages are made using GCC (MinGW) toolchain. It is presently not possible to use these libraries with any recent version of the Microsoft Visual C compiler because of conflicting C-runtimes. To help you resist the temptation, the import libraries (.LIB) are not provided at all. If you need these libraries in an environment which mandates the use of the Microsoft toolchain, you will have to build them from source yourself."

          I'm using MinGW 64-bit.

          mrjjM Offline
          mrjjM Offline
          mrjj
          Lifetime Qt Champion
          wrote on last edited by mrjj
          #4

          @Hound
          Hi
          Ok so it sounds like its a C
          library compiled with MinGW and in 64 bit which should match ok.
          Normally it would be number one suspect.

          Does it crash inside htmlParseFile ?

          I tried the same as you using
          http://xmlsoft.org/sources/win32/64bit/
          libxml2-2.9.1-win32-x86_64.7z
          and it seems its from 2013 and
          minge 7.3 that comes with Qt seems not to like to load it.
          (same silent crash as yours)

          From which date is the ibxml2-2.9.1-win32-x86_64 you downloaded from ?
          I think you might need to recompile the lib yourself as
          mingw back then and mingw now might not be compatiable on windows.

          Anyway, if you just want a working xml parser that is not the one in Qt then
          https://pugixml.org/
          is highly recommneded.

          1 Reply Last reply
          2
          • H Offline
            H Offline
            Hound
            wrote on last edited by
            #5

            Hello!
            The problem was fixed by recompiling the lib with the newest 8.1 MinGW compiler, and configuring QT to compile with it as well.
            This was also needed in .pro file:

            win32: LIBS += -lws2_32
            

            Quite a hassle, but glad it worked out finally. Thanks for the help!

            1 Reply Last reply
            2

            • Login

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