[Development] Using mexFunctions with QT in Matlab 2014
krueger at ind.rwth-aachen.de
Wed Jul 2 18:00:29 CEST 2014
I have created a mexFunction that allows to open QT dialogs etc in
Matlab. What it does is to
create a QT thread - which is not the main thread - and to allocate all
dialogs within this thread.
This principle works very well in Windows /Visual Studio but it does no
longer work in Linux :
Matlab 2014 comes along with the QT 4.8.xx libraries. If I load the
mexFunction by calling the
entry function, Matlab crashes. From the callstack I see that in the
program flow, functions are addressed
which are located in shared library libQt5Gui.so but as soon as some QT
core functionalities are requested,
a function is called which is located in libQtCore.so deployed in the
context of QT4!
It sems that in Microsoft Windows, each DLL is treated in a separate
logical space making it impossible
to call a function in the wrong library. In Linux, however, it seems
that even when using shared libraries,
all symbols are thrown into one pool of symbols and it is never sure
which symbol is taken in a call.
And there seem to be duplicate symbols in QT4 and QT5.
Is there a chance to influence this behavior in Linux to achieve a
behavior as that in Microsoft Windows?
Does anyone have another idea for a work around?
Ah, by the way, I tested also the LD_PRELOAD option to force use of
Qt5Core library. In that case, Matlab
crashes right after boot showing that it is the other way around: Matlab
calls a QT4 function which finally
ends up in libQt5Core.so.
Thank you for any hints,
More information about the Development