Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
Crash when calling function from external library (libxml2)
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 ?
Those binaries, what compiler are those for?
and what compiler are you using ?
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.
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
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
is highly recommneded.
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!