[Development] Using mexFunctions with QT in Matlab 2014

Hauke Krüger krueger at ind.rwth-aachen.de
Thu Jul 3 16:43:09 CEST 2014

Hi Olivier,

it took some time to recompile everything but it now works!
Thank you very much for this valuable hint.

Best regards


Am 02.07.2014 18:24, schrieb Olivier Goffart:
> On Wednesday 02 July 2014 18:00:29 Hauke Krüger wrote:
>> Hi everyone,
>> 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.
> You may solve this problem by compiling Qt within a different namespace.
> (-qtnamespace option in Qt's configure)

More information about the Development mailing list